3

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.

2 Answers2

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?

  1. Create an .xcconfig file (with content like example).
  2. Set up the .xcconfig file in project settings's Info tab (not target's Info tab).
  3. In target's Build Settings tab, ensure PRODUCT_BUNDLE_IDENTIFIER is not bold (click it and press delete).

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:

  1. You want to use some environment as prefix, but above I use PRODUCT_NAME as suffix (simply edit as you wish).
  2. The mylib.xcconfig file sets MYLIB_BUNDLE_PREFIX, and is outside of my MyLib.xcodeproj file's directory (so is in parent project's config directory, I describe in MyLib's README.md that users should create it there).
  3. So, beside showing my #include approache, I try to introduce use of environment-variable.
Top-Master
  • 7,611
  • 5
  • 39
  • 71