2

Today is my day to suffer through Xcode 4, Workspaces, and Projects.

I have a workspace with a few open source libraries (openssl, sqlcipher, and a couple of others). Within the workspace there is one "Main" project which produces an EXE as a target. The open source projects are "subprojects" or "child projects" to the "Main" project. It looks similar to below:

Main Project
  +- OpenSSL Project
  +- SqlCipher Project
  ...

In the "Main" project, under "Project" (rather than "Target"), I set preprocessor and warning flags build settings. For example, the debug preprocessor macros are "DEBUG=1 SQLITE_DEBUG=1 SQLITE_HAS_CODEC=1" (without the quotes). Conversely, release preprocessor macros is set to "NDEBUG=1 NS_BLOCK_ASSERTIONS=1 SQLITE_HAS_CODEC=1".

In the Main "Target" (not "Project") and all subprojects (both "Project" and "Targets"), I ensure there are no project-specific build setting overrides (by highlighting "Preprocessor Macros" and pressing COMMAND+DELETE). I then ensure the field is set to "$(inherited)" (without the quotes).

Lo and behold, the child projects do not honor "$(inherited)". When I look at the command line issued by Xcode, nothing is present that should be present from GCC_PREPROCESSOR_DEFINITIONS. For example, the SqlCipher's project files are not compiled with the inherited build settings from Main.

I thought the problem might be similar to Preprocessor Macros ignored in XCode's project settings, but not target settings, but I can't seem to get the same [positive] results.

Could anyone explain to me how to get child projects to honor "$(inherited)"? As I try to read through Apple's documentation, I only get more confused by what I read and the behavior I observe. Please explain it as if you were talking to a child.

Community
  • 1
  • 1
jww
  • 97,681
  • 90
  • 411
  • 885

1 Answers1

3

These settings don't cross project boundaries. I recommend you configure your targets using .xcconfig files instead (these may be referenced by multiple projects).


Update/Explanation: Using your example setup: The build settings for Main Project may affect any of Main Project's targets, but they won't cross over to OpenSSL Project's targets.

justin
  • 104,054
  • 14
  • 179
  • 226
  • Forgive my ignorance Justin. First, what does $(inherited) mean in Xcode? Second, why does Xcode display a hierarchical (parent/child) format if the relationship does not exist? (I'm at wits end with dealing with all the [software] crap that comes out of Cupertino). – jww Nov 12 '12 at 01:39
  • 2
    @noloader re `$(inherited)`: suppose you have defined `GCC_PREPROCESSOR_DEFINITIONS` at the project level. if you have more to specify at the target level, and you merely define them without using `$(inherited)`, then the project level definitions will be ignored. where you use `$(inherited)`, the build settings at the previous level will be added. otherwise, you would have to manually copy the definitions from all layers of the build settings manually. – justin Nov 12 '12 at 01:46
  • 1
    @noloader b) because the project level settings are applied to that project's targets. the project level build settings do not alter or expand to referenced projects' targets (e.g. subprojects or dependencies). the relationship of project build settings is to the project's targets. – justin Nov 12 '12 at 01:58
  • 1
    Thanks Justin. I guess my point of confusion. "Main" is the main project that has a target to builds an EXE. There is a Xcode Configuration (there is an configuration file in xcshareddata). I believe all [child] projects are using it (or are supposed to use it). As I said, more [software] crap from Cupertino. Their entire QA department should be fired, and a new set of ID10Ts brought in. – jww Nov 12 '12 at 02:56
  • 1
    @noloader i suspect you are referring to a shared `.xcscheme` file (does not define build settings), and not a Build Configuration Settings File (`.xcconfig`). – justin Nov 12 '12 at 03:17
  • 1
    example: http://stackoverflow.com/questions/6208224/how-can-i-use-xcconfig-files-in-xcode-4 – justin Nov 12 '12 at 03:18
  • 1
    Thanks Justin. So I just checked.... The top level project has the Xcode Configuration file. The child projects don't have it selected, and I can't select the xcconfig file either. Apple and Xcode sucks. – jww Nov 12 '12 at 03:28
  • Great reference, by the way. I already had it open in the browser. – jww Nov 12 '12 at 03:29
  • @noloader you're welcome. you just need to add that `.xcconfig` to all applicable projects, then associate it (as you have already done with your meta-project). – justin Nov 12 '12 at 04:18