tags:

views:

18

answers:

1

Hi everyone,

If i added a user-defined setting in my build configuration, how can i read that setting in my objective-C files. I have two files in my project debug.plist and release.plist. I want my MainApp.m file to read one of these files based on which build configuration is running. I set up a user-defined setting named "filename" in both Debug and Release configuration point to the appropriate file. But i dont know how my MainApp.m file and read the filename variable from the current running configuration. Thank you.

+1  A: 

Your code can't read arbitrary build settings. You need to use preprocessor macros.

EDIT: For example, in the target settings for the Debug configuration, you could add DEBUGGING=1 in the Preprocessor Macros build setting, and not define DEBUGGING in the Release configuration. Then in your source code you could do things like:

#if DEBUGGING
  use this file
#else
  use the other one
#endif
JWWalker
Thanks, JWWalker, can you show me how to define a preprocessor macros specifically for xcode project?
Super Cat
OK, I added an example to my answer.
JWWalker
P.S. There is one way to use a user-defined setting: Check "Expand Build Settings in Info.plist File", then you can use `$MYSETTING` in the Info.plist file.
JWWalker