Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing preprocessor defines from an XCode5 project to its contained sub-projects

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).

like image 529
user3756504 Avatar asked Jun 19 '14 12:06

user3756504


1 Answers

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'

like image 69
Jay Koutavas Avatar answered Nov 15 '22 05:11

Jay Koutavas