Xcode changes the global variable for each target

I have a number of goals, and each of them looks at a global variable that I currently store in the constant file for the name of the directory in which these applications live. However, this means that I have to change this value every time I change the goal, which is a terrible process.

What is the best way to change this value for each goal? Or should I indicate this value somewhere in my target plist? If so, how can I get this value?

Thanks!

+4
source share
2 answers

With the project open in Xcode, view the Groups and Files panel for your purpose. Right click to open popup menu. Select Get Info. Select the assembly tab. Scroll down to “Preprocessor Macros” and add something like “MY_OPTION_1”. Do something similar for other purposes. Say "MY_OPTION_2", "MY_OPTION_3", etc.

Now in your code you can run the define test. how

#ifdef MY_OPTION_1 // define values here #endif #ifdef MY_OPTION_2 // define values here #endif #ifdef MY_OPTION_3 // define values here #endif 

Then, depending on the purpose used, the values ​​in the respective definitions are used.

+8
source

Go to your target properties by double-clicking on it and find the preprocessor macros. Add a constant, for example FILE_PATH="/some/place/green/" , and then when you want to use it, just

fopen(FILE_PATH... or any function / method that you want to execute on FILE_PATH

make part of the definition for each goal.

0
source

All Articles