Re: transferring preprocessor macros (or similar) to project dependencies
Re: transferring preprocessor macros (or similar) to project dependencies
- Subject: Re: transferring preprocessor macros (or similar) to project dependencies
- From: Jessica Kahn <email@hidden>
- Date: Tue, 13 Jan 2009 01:14:56 -0800
Ken, thanks for your suggestion. Happens to be related to one I
received off-list from Chris Hanson, and I've implemented it as follows:
Basically, every new "parent" project needs to include a (newly
created) child.xcconfig file. This file is where we define per-
application build settings that we want to use to conditionally
compile files in the child bundle.
I've added a Copy Files target to each parent project, whose sole job
is to take child.xcconfig and copy it into the child's built products
directory.
I've added an Aggregate target to each parent project, that first
builds that Copy Files target, and then builds the parent application
target. That appears to be required to get the Copy Files thing to
happen before the Child.bundle build is done. I couldn't just insert a
Copy Files build phase prior to the bundle build; Xcode wouldn't let me.
Then, in the child project, I've changed the build for all
configurations to be "based on" the child.xcconfig file, located in
its built products directory.
Sounds a little clunky and complicated in my description (which I
detailed just in case this would help somebody in the future), but
ultimately does exactly what I need it to do, and works like a charm!
Thanks again, to both Ken and Chris!
--Jess
On Jan 12, 2009, at 9:25 PM, Ken Thomases wrote:
On Jan 12, 2009, at 7:40 PM, Jessica Kahn wrote:
I'd like to conditionally compile sources during the bundle build,
based on settings that are unique to each application build.
Ideally it'd be something like being able to set a preprocessor
macro "FEATURE_FOO_ENABLED=1" in one of the application projects,
and have that macro definition carried through to, and used during,
the build of the loadable bundle in Child.xcodeproj.
Did some reading, and ended up finding that I may need to do this
by setting environment variables during the build. Apparently the
scope of the environment is the one that will apply to both the
Parent.xcodeprojs and the Child.xcodeproj, both.
My questions:
1) Is this the right direction to be taking? Is the environment the
place to set these settings?
I would say no. When you think about it, having FEATURE_FOO_ENABLED
or not produces two distinct variations of the bundle. These two
variations should be represented by two build configurations in the
child project.
Then, one parent project would use one of the configurations and the
other would use the other configuration. Xcode will use a
configuration when building the bundle which is named the same as
the parent project's configuration, if it finds one.
Cheers,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden