-
Set up Settings.bundle in Xcode: https://medium.com/@abhimuralidharan/adding-settings-to-your-ios-app-cecef8c5497
-
Go in to xcode and choose your taget. In the Build phases tab, add a new Run Script Phase.
-
Set
Shell
to/bin/bash
, and copy theupdate_version_settings_bundle.sh
into the run script.
-
-
Save caroillemann/0a2af95c7224527630f0d424ad18bee5 to your computer and use it in GitHub Desktop.
Add version in Settings.bundle for iOS apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works just fine. Thx!