I need to build an Xcode project within a Today Extension by 'xcodebuild'. The bundle is of the main target is com.myapp, while the bundle id of the extension is com.myapp.todayextension. I'd like to pass both the bundle id's as parameters of xcodebuild: I tried to replace the bundle id's in the xcode project by custom environment variables (e.g. ${MAIN_TARGET_BUNDLEID} and ${EXTENSION_BUNDLEID}) but the xcodebuild fails. Could you please help me with the correct syntax of xcodebuild command ? Thanks.
Asked
Active
Viewed 1,250 times
2 Answers
1
That's called PRODUCT_BUNDLE_IDENTIFIER, as per the documentation.
Ben Butterworth
- 22,056
- 10
- 114
- 167
0
Better too late than never; We can't directly use an environment variable in General tab, you will need to go into Build Settings tab, then set Product Bundle Identifier to your environment-variable, for example $(PRODUCT_NAME).
See below for another approach.
How to load prefix set by parent project?
- Create an
.xcconfigfile (with content like example). - Set up the
.xcconfigfile in project settings'sInfotab (not target'sInfotab). - In target's
Build Settingstab, ensurePRODUCT_BUNDLE_IDENTIFIERis not bold (click it and pressdelete).
But Podfile users should see also: How to make Xcode use multiple xcconfig files?
Example
My extension.xcconfig file (which is in MyApp/MyLib/MyExtension directory), looks something like:
// Below loads `MyApp/config/mylib.xcconfig` file.
#include "../../config/mylib.xcconfig"
PRODUCT_BUNDLE_IDENTIFIER = $(MYLIB_BUNDLE_PREFIX).$(PRODUCT_NAME)
Note that:
- You want to use some environment as prefix, but above I use
PRODUCT_NAMEas suffix (simply edit as you wish).- The
mylib.xcconfigfile setsMYLIB_BUNDLE_PREFIX, and is outside of myMyLib.xcodeprojfile's directory (so is in parent project'sconfigdirectory, I describe in MyLib'sREADME.mdthat users should create it there).- So, beside showing my
#includeapproache, I try to introduce use of environment-variable.
Top-Master
- 7,611
- 5
- 39
- 71