To display the current version of an iOS app in the settings
- Add an entry like this in
Settings.bundle/Root.plist
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
<key>Title</key>
<string>Version</string>
<key>Key</key>
<string>version_preference</string>
<key>DefaultValue</key>
<string></string>
</dict>
...
</array>
- Add a new
Run Script
phase in the build phase to the target like this
cd $PROJECT_DIR
cd "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app"
RELEASE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" Info.plist)
BUILD_NUMBER=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" Info.plist)
VERSION_STRING="$RELEASE_VERSION ($BUILD_NUMBER)"
/usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:0:DefaultValue $VERSION_STRING" Settings.bundle/Root.plist
👍🏻