Skip to content

Instantly share code, notes, and snippets.

@caroillemann
Forked from hujunfeng/Root.plist
Last active April 6, 2021 02:50
Show Gist options
  • Save caroillemann/0a2af95c7224527630f0d424ad18bee5 to your computer and use it in GitHub Desktop.
Save caroillemann/0a2af95c7224527630f0d424ad18bee5 to your computer and use it in GitHub Desktop.
Add version in Settings.bundle for iOS apps
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Versionsoplysninger</string>
</dict>
<dict>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
<key>Title</key>
<string>Version</string>
<key>Key</key>
<string>version_preference</string>
<key>DefaultValue</key>
<string>XX</string>
</dict>
<dict>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
<key>Title</key>
<string>Build</string>
<key>Key</key>
<string>build_preference</string>
<key>DefaultValue</key>
<string>XX</string>
</dict>
</array>
</dict>
</plist>
#!/bin/bash
# Add a Run Script in Build Phase and put in the content of this script
PLISTBUDDY="/usr/libexec/PlistBuddy"
INFO_PLIST="$CODESIGNING_FOLDER_PATH/Info.plist"
SETTINGS_PLIST="$CODESIGNING_FOLDER_PATH/Settings.bundle/Root.plist"
VERSION_NUMBER="`$PLISTBUDDY -c \"Print CFBundleShortVersionString\" \"$INFO_PLIST\"`"
BUILD_NUMBER="`$PLISTBUDDY -c \"Print CFBundleVersion\" \"$INFO_PLIST\"`"
VERSION="$VERSION_NUMBER ($BUILD_NUMBER)"
$PLISTBUDDY -c "Set :PreferenceSpecifiers:1:DefaultValue '$VERSION_NUMBER'" "$SETTINGS_PLIST"
$PLISTBUDDY -c "Set :PreferenceSpecifiers:2:DefaultValue '$BUILD_NUMBER'" "$SETTINGS_PLIST"
@jorgenisaksson
Copy link

Works just fine. Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment