Search code examples
iosxcodexcodebuildinfo.plistcodesign

xcodebuild will codesign with Xcode 6 and alternate bundle ID but not with Xcode 7


Our CI server does a daily ad-hoc build of our app by swapping in a different bundle ID like this:

/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.example.app.daily" \
  app/app-Info.plist

and then building and archiving with xcodebuild:

xcodebuild \
  CODE_SIGNING_REQUIRED=YES \
  CODE_SIGN_IDENTITY="$DEVELOPER_NAME" \
  PROVISIONING_PROFILE="$PROFILE_UUID" \
  -sdk iphoneos \
  -workspace "$XCODE_WORKSPACE" \
  -scheme "$XCODE_SCHEME" \
  clean archive \
  -archivePath "$ARCHIVE_PATH"

with Xcode 6 this worked perfectly, but in Xcode 7 we're getting this error:

Code Sign error: Provisioning profile does not match bundle identifier: The provisioning profile specified in your build settings (“Daily AdHoc Profile for CI Servers”) has an AppID of “com.example.app.daily” which does not match your bundle identifier “com.example.app”.

It's as if Xcode 7 isn't seeing that we changed the bundle ID. Is it looking somewhere else?


Solution

  • @Mozilla pointed me in the right direction. Upgrading to an Xcode 7 project moved the bundle identifier into a "Product Bundle Identifier" setting in the Packaging section of the build settings.

    Xcode's help sidebar revealed that this setting was named PRODUCT_BUNDLE_IDENTIFIER. So my command became:

    xcodebuild \
      CODE_SIGNING_REQUIRED=YES \
      CODE_SIGN_IDENTITY="$DEVELOPER_NAME" \
      PROVISIONING_PROFILE="$PROFILE_UUID" \
      PRODUCT_BUNDLE_IDENTIFIER="com.example.app.daily" \
      -sdk iphoneos \
      -workspace "$XCODE_WORKSPACE" \
      -scheme "$XCODE_SCHEME" \
      clean archive \
      -archivePath "$ARCHIVE_PATH"
    

    and it worked!