I want to detect an environment variable outside of Xcode’s settings. I can do this at runtime checking the environment like specified in Detecting if iOS app is run in debugger, but is there a way to do it with a preprocessor macro like this?
#ifdef USER_GRADHA
// do some stuff
#else
// do other stuff
#endif
My environment variable is set, but it is not reaching the compilation phase of the .m files. I want to accomplish this without having to modify the project’s preprocessor macro variable, because I want compilation to be different for each user without them having to modify it.
No. Compilation is very intentionally a deterministic process and does not depend on the outside environment. The only way I know of for compilation to differ based on who’s compiling is via the Source Trees preference in Xcode, and that’s explicitly intended for users to keep source trees in different locations on different machines but have the build setting be the same (because it can refer to the source tree location set in the preferences).