Version and build in the IOS project
Version's key in the plist file is "cfbundleshortversionstring", which identifies the release version number of the application and is consistent with the version number on the App store. The version number of this version is a string consisting of three separate integers. The first integer represents a substantially modified version, such as a revision that implements a new feature or significant change. The second integer represents the revision, which achieves a more prominent feature. The third integer represents the maintenance version
The key to build in the plist file is "Cfbundleversion", the build number that marks (publishes or is not published). This is a monotonically increasing string, consisting of one or more divided integers.
The above two versions can be obtained in the following ways:
Nsdictionary *infodictionary = [[NSBundle mainbundle] infodictionary];
App version
nsstring *app_version = [infodictionary objectforkey:@ "cfbundleshortversionstring"];
App build version
nsstring *app_build = [infodictionary objectforkey:@ "cfbundleversion"];
Scripting to automatically grow the build version number after archive
If we want to grow automatically after the archive, we can use the run script to Xcode, and the steps are
- Select target for the item and click "Build Phases"
- Click on the "Add Build Phrase" in the lower-right corner and select "Add Run Script" to produce a new run script item
- Drag the newly generated run script item to the top
- Click on the item, copy the following shell code in, the code from here, as shown in the following figure
if [$CONFIGURATION = release]; Then
echo "bumping build number ..."
Plist=${project_dir}/${infoplist_file} #increment The build number
( IE to 116)
buildnum=$ (/usr/libexec/plistbuddy-c "Print cfbundleversion" "${plist}")
if [["${buildnum}" = " " ]]; Then
echo "No build number in $plist"
exit 2
fi
buildnum=$ (expr $buildnum + 1)
/usr/libexec/ Plistbuddy-c "Set cfbundleversion $buildnum" "${plist}"
echo "bumped build number to $buildnum"
else
echo $CONFIGURATION "Build-not bumping build number."
Fi
What this shell script means is that if the current configuration is release (archive when the value is release, and run directly on the emulator is debug), the build value is set to the current build value of +1, otherwise nothing will be done.
That way you'll see the build number automatically adds 1 when you build it, and you want to see the information that comes out of the build, and you can view the log from the latest build with the view-> Navigators-> log.
Thank you for reading, I hope to help you, thank you for your support for this site!