Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PlistBuddy or code to display version information iOS

I am adding "Version Detail" in settings.bundle. What could be a better way to set that identifier, I have seen few do it through code other's use the run script with Plistbuddy.

Is it like that if you use plistbuddy, it show's the updated version details immediately even if you do not open the app. after version update from app. store?

If done through code, one has to open the app. to see the update in the settings.

like image 933
NNikN Avatar asked Jun 15 '14 02:06

NNikN


1 Answers

Here's a PlistBuddy example:

#
buildPlist="Info.plist"
settingsPlist="Settings.bundle/Information.plist"

# Get the existing buildVersion and buildNumber values from the buildPlist
buildVersion=$(/usr/libexec/PlistBuddy -c "Print CFBuildVersion" $buildPlist)
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBuildNumber" $buildPlist)

# Increment the buildNumber
buildNumber=$(($buildNumber + 1))

# Set the version numbers in the buildPlist
/usr/libexec/PlistBuddy -c "Set :CFBuildNumber $buildNumber" $buildPlist
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildVersion.$buildNumber" $buildPlist
# Set the version numbers in the settingsPlist
/usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:1:DefaultValue $buildVersion.$buildNumber" $settingsPlist

Hope that helps!

like image 101
Jim Avatar answered Nov 15 '22 04:11

Jim