2

I have an iOS app in which i have a settings bundle. The root.plist is:

Settings.bundle's root.plist

When I manually change the Item6>Titles>Item0's value and run it, it reflects the changes in device's settings page for the app.

Now, I did a run script to set build version to this field

build=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" 
${PROJECT_DIR}/${INFOPLIST_FILE}`
/usr/libexec/PlistBuddy "$SRCROOT/Settings.bundle/Root.plist" -c "set PreferenceSpecifiers:6:Titles:0 $build"

The specified value for the item in Root.plist is changed (as I can see through Xcode) but it doesn't seem to be reflecting in the settings of the application on device.

Any idea why? Any fix for this weird issue? Am I missing something?

Ocelot
  • 1,733
  • 4
  • 29
  • 53

1 Answers1

1

The Root.plist allows you to specify default values. Default values are only used in the settings app (or when programmatically accessing the NSUserDefaults) as long as there is no real value set to the property, either programmatically or by the user. Once a value is set (you mentioned, that you manually set the version for testing purposes), the default value is ignored.

Simply delete your app (settings will also be deleted) and restart it. The settings app on the device will show your new default value.

Christian
  • 357
  • 3
  • 13
  • of course it does, once the app is deleted. But i wouldn't want the user to delete and re-install the app every time there's a new release – Ocelot Oct 14 '14 at 23:01
  • 1
    That's why setting the default value of a property in the Root.plist is the wrong approach. You have to update this NSUserDefaults-property every time your app is started. I just wanted to answer your question, why this is happening. ;) There is no fix for this behaviour as it is working as designed. – Christian Oct 15 '14 at 11:52