I have a Xcode5 project (A) that is dependent on another XCode5 project (B). Project B is contained as sub-project in Project A. Project B needs to be passed a preprocessor define from project A, but this seems to be an impossible task. By design, preprocessor defines are not passed from one parent XCode project to its sub-projects. I've tried setting an environment variable in the XCode Scheme and picking that one up in project B, but that didn't work either. I've no idea how to do this, although I've passed a whole morning on it already...
Important side note: I don't want to change anything in Project B, because it's a project that will be used by many parent projects, and changes (i.e. preprocessor defines) should only be made in the parent projects, but never in project B.
Edit: A very simple possibility would be to have some "config.h" header file with some preprocessor defines in Project A, and Project B would include this file. But without specifically adding the directory of that file to the header include directories of Project B, I don't know how to tell XCode to find this file (again: I never want to makes changes to project B).
Your request is best served with xcconfig. See this article: https://medium.com/@derrickho_28266/super-preprocessor-directives-with-xcode-8-77bf4d4e5a0c
Alternatively, you can pass definitions all the way down from project to subproject(s) from the command line, like this: xcodebuild -project TopLevelProject.xcodeproj GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS FOOBAR=1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With