18

I have a multi-target iPhone app which currently includes a header file with constant definitions that are conditionally included at build time depending on which target is being built.

However, I was wondering if it might be better to instead include this information in the info.plist for the build, as this generally holds target-specific meta, so logically seems more appropriate.

Therefore, my questions are:

  1. Is it acceptable to include custom (non-Apple defined) keys in the info.plist file?
  2. Is this a suitable place to include meta for the app which differ between targets?
CVertex
  • 17,997
  • 28
  • 94
  • 124
andybee
  • 1,142
  • 3
  • 15
  • 26

1 Answers1

17

It is acceptable and suitable.

The Info.plist file is preprocessed (must be enabled in project settings by setting Packaging / Preprocess Info.plist File to Yes) by the C pre-processor, so you can have variables (in the form of ${VARIABLE_NAME}). These variables can be defined in the User Defined section in Xcode's target info, making it very easy to switch their value from one target to another.

Pavel Zubkou
  • 825
  • 9
  • 13
pgb
  • 24,813
  • 12
  • 83
  • 113
  • Excellent, no idea why I never twigged with Apple's own use of variables but this means my multiple info.plist's could actually be simplified to one and just drop the variables in via the pre-processor during compilation. Makes more sense to me to tweak the drop the settings in at compilation. – andybee Jun 07 '10 at 14:54
  • I'm not sure what you mean. You can set the value in the Get Info pane for your project. – pgb Jul 23 '10 at 15:13
  • 1
    You can grab that dictionary with `NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];` – pgb Oct 22 '13 at 12:25