tags:

views:

395

answers:

2

It's simple to set a property in an Info.plist file from a user defined setting, you just use ${YOUR_SETTING_NAME} as the value. However, is it possible to do this for a bolean property? The structure in the plist file for a boolean is:

<key>NSAppleScriptEnabled</key>
<false/>

It's not clear how to use a user defined setting here.

A: 

What do you mean by "User Defined Setting" ...

If the user you are talking about is you (in other words, the app's developer), then you can just put whatever keys you want there, just like any other plist in your Xcode project.

If the user you are talking about is your app's end user, don't try to save their settings in your Info.plist. It is a part of the application. While it is sometimes possible for an app to change its own info plist on a mac, it often is not, depending on how the app was installed. On the iPhone it is never possible, since the app is read-only. In either event, changing your Info.plist would invalidate any app signing you have done.

If you want to change end user settings, use something NSUserDefaults.

Louis Gerbarg
Hi Louis. I believe he's talking about a user-defined XCode Build setting on the Mac.
Ken Aspeslagh
See the accepted answer above. I have multiple targets in the project sharing a single Info.plist. I'm using User Defined Settings on each target to configure the values in Info.plist. One of them is a boolean and it's not (or wasn't) clear how to substitute these.
edoloughlin
+1  A: 

I'm not sure how to do what you're asking, but I'm pretty sure that for this particular key (NSAppleScriptEnabled) you can also use strings "YES" and "NO" and it will work.

Ken Aspeslagh
It works if you set the variable (setting) type in Info.plist to String (not boolean) and then use 'YES' and 'NO'. Thanks.
edoloughlin