Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Info.plist and its variables like ${APPNAME}

Tags:

ios

plist

I am preparing Info.plist for my iOS application. I want to carefully set each option. However, there are some weird variables like ${REGION}, ${APPNAME}, ${EXTRA_ICONS}, etc. I guess they are set via Xcode?

I don't want Xcode to mess with the values. Can I simply set them? For example, for ${REGION} insert "en". For CFBundleDisplayName – nothing, because the docs says:

If you do not intend to localize your bundle, do not include this key in your Info.plist file. Inclusion of this key does not affect the display of the bundle name but does incur a performance penalty to search for localized versions of this key.

And so on. Can I simply do this? What to insert for "CFBundleExecutable"? I guess I have to know what Xcode generates?

This is horrible design, as there are two sources of values: the plist itself, and some stupid meta-plist inside Xcode.

like image 602
AllCoder Avatar asked Sep 13 '12 20:09

AllCoder


People also ask

What is the info plist file?

plist file. When you use Dynatrace, the Info. plist file stores your app identification and configuration keys.

How do I read a plist file on a Mac?

Launch Finder, click Macintosh HD under Locations. Next, input '. plist' in the searching box on the right top of the window, all the plist files will be listed as follows. Then you can open and edit the plist file in macOS by using Xcode or Apple Property List Editor.


1 Answers

Your Info.plist file is processed by Xcode thanks to the "Expand Build Settings in Info.plist Files" (INFOPLIST_EXPAND_BUILD_SETTINGS) Build Setting of your Project.

That's usually a great feature, as it avoids to have a different Info.plist depending on your build settings and configuration, and avoids you to modify the settings in multiple places. But if you really don't want it, simply turn this settings off in the Build Settings of your project or target.


I suggest you keep this setting on anyway, so that the values chosen in your build settings will be reported in your Info.plist, and if you need to change stuffs like the application name for example, change it in the Build Settings directly. This way you will keep consistency between your build settings and your Info.plist file, instead of risking to have an inconsistent configuration.

A great example is the one you wrote yourself in your own question : the CFBundleExecutable entry of the Info.plist file. This entry typically have to contain the name of the executable in your bundle (so that iOS knows which executable to launch inside your .ipa bundle).

This value typically depends on your Build Settings, typically the EXECUTABLE_NAME build setting. If you ever change the name of the generated executable (in the Build Settings of your project or target) and you did put some constant string for this value in the Info.plist, you obviously need to change this CFBundleExecutable key to the new name of the executable generated by Xcode. If you use ${EXECUTABLE_NAME} as the value for this key (and kept the processing of your Info.plist turned on in the project settings), Xcode will replace it for you, ensuring that the Info.plist is consistent with your Build Settings and with the name of the executable it has generated.

I don't see any advantage of disabling this processing phase of the Info.plist file by Xcode ; you should take advantage of it and keep using the ${xxx} build variables so they are replaced by their real values Xcode dynamically at compile time thus ensuring consistency and avoiding errors.

like image 106
AliSoftware Avatar answered Oct 11 '22 16:10

AliSoftware