Cocoapods: xcodebuild failure due to bundle identifier mismatch

Created on 7 Apr 2015  Â·  15Comments  Â·  Source: CocoaPods/CocoaPods

After switching from wildcard provisioning profile to a profile with unique bundle identifier, I'm no longer able to build project from command line with xcodebuild, but building in Xcode is still fine. In my Xcode project Code Signing Identity is set to a development identity for all configurations and Provisioning Profile is set to Automatic (I didn't touch the Pods project).

My script invokes xcodebuild with the following params:

xcodebuild -workspace "${WORKSPACE_NAME}" -scheme "${SCHEME_NAME}" -configuration "AdHoc" -sdk "iphoneos" SYMROOT="$(pwd)/build" CODE_SIGN_IDENTITY="iPhone Distribution: ..." PROVISIONING_PROFILE="..."

xcodebuild output (it's from jenkins, but on local machine there's the same issue):

Build settings from command line:
    CODE_SIGN_IDENTITY = iPhone Distribution: ...
    PROVISIONING_PROFILE = ...
    SDKROOT = iphoneos8.2
    SYMROOT = /Users/admin/.jenkins/jobs/autobuild/workspace/build

=== BUILD TARGET Pods-AFNetworking OF PROJECT Pods WITH CONFIGURATION AdHoc ===

Check dependencies
Code Sign error: Provisioning profile does not match bundle identifier: The provisioning profile specified in your build settings (“My Cool App AdHoc”) has an AppID of “my.cool.appId” which does not match your bundle identifier “org.cocoapods.AFNetworking”.
CodeSign error: code signing is required for product type 'Framework' in SDK 'iOS 8.2'

...

** BUILD FAILED **

The following build commands failed:
    Check dependencies
    Check dependencies
(2 failures)

I was able to fix those errors by setting my app's AppID to all pods' info.plist, but I'm not sure if it's actually the proper way... Update: this leads to app installation failure on device/simulator.

My podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

xcodeproj 'MyCoolApp', 'AdHoc' => :release, 'AppStore' => :release

pod 'AFNetworking', '~> 2.5'
pod 'Parse', '~> 1.7'

# TODO: use release version as soon as fix is released
# pod 'HockeySDK', '~> 3.6'
pod 'HockeySDK', :git => 'https://github.com/bitstadium/HockeySDK-iOS.git', :branch => 'develop'

I'm using fresh cocoapods:

$ pod --version
0.36.3

Most helpful comment

@ryanjohnstone @kambala-decapitator Here is a neat solution on StackOverflow: http://stackoverflow.com/a/29605731/646960. Basically you set your provisioning profile as $APP_PROFILE in Xcode, and pass APP_PROFILE="<PROFILE_UUID>" to xcodebuild instead of PROVISIONING_PROFILE. It fixed the issue for me.

All 15 comments

I'm having the same issue, did you manage to resolve it?

@ryanjohnstone in the end I had to remove the use_frameworks! to make pods build as static libs, but it's definitely not a solution for the issue

@ryanjohnstone @kambala-decapitator Here is a neat solution on StackOverflow: http://stackoverflow.com/a/29605731/646960. Basically you set your provisioning profile as $APP_PROFILE in Xcode, and pass APP_PROFILE="<PROFILE_UUID>" to xcodebuild instead of PROVISIONING_PROFILE. It fixed the issue for me.

@ldiqual Works for me too with Jenkins builds :+1:

Has anyone figured this out yet? I am facing the same issue with no workarounds...

@blumist what about @ldiqual's workaround?

I would need to post install to update the provisioning profile parameters in the pods?
Semi-related, would I be able to update the bundle identifiers with post install?

+++1 I wasted an entire day on this. The workaround didn't change a thing for me

I'm making Enterprise Release builds using jenkins and have this issue.
Do i understand correctly, that the APP_PROFILE solution requires a second Provisioning Profile?
With what data? Wildcard (*) for the pods?

Set your Project Settings To:

  • Debug Code Sign = iOS Developer
  • Release Code Sign = iOS Distribution
  • Debug Prov Profile = $APP_PROFILE
  • Release Prov Profile = $APP_PROFILE

Set your Target Settings To:

  • Debug Prov Profile = Automatic

(inherit the others)

This works for me at least passing the APP_PROFILE=xxxx via xcodebuild.

Seems like we can close this issue as APP_PROFILE works and there's also the possibility to specify code signing settings via post-install as described in #3198

For anyone else struggling with this:

Make sure your project's Provisioning Profiles are set to Automatic, and its Code Signing Identities are iPhone Developer or iPhone Distribution. In the actual target you override provisioning profiles with your specific ones.

Now when archiving using xcodebuild, make sure CODE_SIGN_IDENTITY exactly matches the implicit name of your target's Code Signing Identity (click on the target's Code Signing Identity for your configuration to see which one it matches).

In my case, I had set the CODE_SIGN_IDENTITY to iPhone Distribution: Company Name (identifier), but my target specified: iPhone Distribution: Company Name without the identifier. This was working up until I started using frameworks instead of static libraries, since frameworks have to be signed.

with latest Xcode and cocoapods setting PROVISIONING_PROFILE directly on command line works fine

I'm having the same issue, did you manage to resolve it?
Now I just add

 post_install do |installer|
        installer.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
                config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
                config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
            end
        end
    end

then I resoved this problem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gerchicov-bp picture gerchicov-bp  Â·  3Comments

pallaviMN picture pallaviMN  Â·  3Comments

hmistry picture hmistry  Â·  3Comments

steffendsommer picture steffendsommer  Â·  3Comments

Curtis-Halbrook picture Curtis-Halbrook  Â·  3Comments