Re: pass info to subproject
Re: pass info to subproject
- Subject: Re: pass info to subproject
- From: Bill Garrison <email@hidden>
- Date: Sat, 14 Jan 2012 11:00:58 -0500
On Jan 13, 2012, at 5:55 PM, Torsten Curdt wrote:
> Is there a way to pass information from a parent project down to a subproject?
> More specifically I want to pass the parent bundle id and use it as
> prefix for the subproject bundle id.
>
> Any suggestions?
Torsten,
It might smell of jiggery-pokery, but maybe you could do it using the file system.
1. Use an external shell target in the parent project to write out a file with a macro definition for your parent project's bundle ID. The file must written to a location that can be known to both projects.
#/bin/sh
#
# I use /tmp as the location well known to both parent and subproj. This is not without some risk.
#
echo "#define PARENT_BUNDLE_ID \"$BUNDLE_IDENTIFIER\"" > /tmp/bundle_id.prefix
2. Configure the subproject to preprocess its Info.plist using the file generated from step 1.
INFOPLIST_PREPROCESS = YES
INFOPLIST_PREFIX_HEADER = /tmp/bundle_id.prefix
3. In the subproject's Info.plist, set its CFBundleIdentifier value to ${PARENT_BUNDLE_ID}subproject-bundle-id
With preprocessing on, the PARENT_BUNDLE_ID macro should be defined and available to use in your subproject's Info.plist.
---
I've used this technique within a single project (to pull in a change set identifier from Mercurial to include in my project's Info.plist).
I've not used it before to pass info along to cross-referenced projects. I don't know the timeline that Xcode follows when processing projects and their dependencies. If sub projects are done first, this approach will not work.
If you configure the parent project such that the main target is dependent on the external script target from step 1, maybe Xcode will run it first, *then* process your sub projects and *then* it probably will work.
I can't stress enough how much jiggery-pokery is required here. :-)
Bill _______________________________________________
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