through a custom script i update my CFBundleVersion in my app-info.plist when I build and run the app. This information is used as well in the app to display the app name and version. The update works fine in the build process, but the unfortunatly the old information is read in the app itself.
E.g. When I build and run the app the app-info.plist is updated, the CFBundleVersion
has now the value 8
, but in the simulator the value 7
is shown.
Seems so that the updated app-info.plist is not used in the build process, instead the old version is used.
How can I ensure that the updated app-info.plist is used in my app? On the one hand somehow the execution of the script should be the first thing in the build-process or on the other hand the app-info.plist should be renewed in the build process. But for both I do not know how to do this...
I added the custom script under Project > Buildphases > Add Build Phase > Add Run Script. With the following contents:
shell: /bin/bash Tools/addVersionNumber.sh
Tools/addVersionNumber.sh -> works like desired
#/bin/bash
# script that should be executed in the build phase
# to set the build number correct
plist="app-folder/app-Info.plist"
## get git information
# git_rev_full_hash=$( git rev-parse HEAD )
git_amount_commits=$( git rev-list HEAD | wc -l )
git_rev_short_hash=$( git rev-parse --short HEAD )
buildRevision="$git_amount_commits: $git_rev_short_hash"
# set build revision ( git short hash - amount of commits )
/usr/libexec/PlistBuddy -c "Set :BuildRevision $buildRevision" $plist""
## build number
buildNumber=$( /usr/libexec/PlistBuddy -c "Print CFBundleVersion" $plist )
buildNumber=$(( $buildNumber + 1 ))
# set new build number
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" $plist
cheers -- jerik