简体   繁体   中英

How to Access the Xcode Verison Number like Version 6.1.1 (6A2008a) Programmatically

如何使用OBJ-C或Swift在应用程序中以编程方式获取Xcode Verison编号,如版本6.1.1(6A2008a),因为我有需求,我需要在应用程序设置中获取该数字并显示它,或者它是否可能据我所知,Apple在使用iTunes Connect时会这样做

Just read the contents of /Applications/Xcode.app/Contents/version.plist

You could create a project local file using awk by extracting the version string and add it to the bundle.

I guess you don't change XCode versions like your underwear. So simply create a text file with the version number and stow it somewhere. Then in the Targets settings open the Build Phases and include that file in Copy Bundle Resources. Now in your app you can read that file as it will be part of your bundle.

You can get at this info by running xcodebuild -version in terminal. Following on from this, you can set up a run script build phase to query this and store the output in a file (say, your appinfo.plist ) that you can query at runtime.

For an example of this, see How this blogger adds git information into his app

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM