Saturday, September 15, 2012

Fix the iOS code signing issue when using Jenkins

This week I setup the Jenkins on my Mac and try to build iOS applications. unfortunately I got the code signing issues, either I use xcode plugin or xcode command line tool. Through a couple days of googling and I could not find any solution that works for me, but I finally solve this issue by myself through different try out, and the solution is such an easy, now I would like to share with my solution.

The core reason is Jenkins is running as daemon mode in Mac, just assume it is a different user - "Jenkins", so it will not have access to the keychain or provision profile as a you login using your credentials, which cause the code signing issue.
I found I have following 2 errors

1. "Code Sign error: There are no valid certificate/private key pairs in the default keychain"
Solution: Copy your iPhone developer certificate from "login" keychain to "System" keychain.
Detailed steps:
  open the "Keychain Access" application, click the login tab, right click the certificate like "iPhone Developer: your_name (XXXXXXX)", choose copy, then click the "System" tab, right click mouse, choose "Paste 2 items"; you might need to do the same thing with the certificate like "iPhone Distribution: your_name".

After doing this, you will get the second error.
2. "Code Sign error: Provisioning profile 'xxxxx-xxxx-xxxx-xxxxx' can't be found"
Solution: Copy the provision profile to Jenkins user folder.
The provision profile is under in the folder
/YourUserName/Library/MobileDevice/Provisioning Profiles,
for example in my machine, the provision profile files are under /Users/steve/Library/MobileDevice/Provisioning Profiles
In the mac, the Jenkins will be in /Users/Shared/Jenkins, create the following folder:
/Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profile,  then copy the .mobileprovision file to this folder.

After doing this, the code signing issues will be fixed. Hope my finding will be helpful to other Jenkins users.


  1. It works! THX a lot!!

  2. It took me a while search for an answer, final this page helped me. Thanks Steve!

  3. Typo in the last folder: create /Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profiles and *NOT* /Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profile

    Notice the s at the end.

  4. Thanks, you saved my time

  5. Buddy,... that worked like charm .. got fixed those issues , now started getting other error. BTW thanks!!!

  6. Here is a better solution:

  7. if jenkins is executed as admin, this issue is fixed?

  8. No more to say : thank you !!! You made my day !

  9. Excellent post! This was my last struggle I could't win for long time)

  10. I am configuring CI for my IOS project on MAC yosemite-OS and got on problem:

    error: /usr/bin/codesign --force --preserve-metadata=identifier,entitlements,resource-rules --sign /Users/mitul/Desktop/jenkins_ios_profile/PCertificates.p12 --resource-rules=/var/folders/rj/cc6d38nn53v6tk8y4jn7ghkr0000gp/T/42RbMszHQX/Payload/ /var/folders/rj/cc6d38nn53v6tk8y4jn7ghkr0000gp/T/42RbMszHQX/Payload/ failed with error 1

    even my build and archive are getting success but not able to make .ipa file

    even tried all possibilities from this /usr/bin/codesign failed with exit code 1 but no luck

    Please help me what I am missing to do

    My Xcode configuration is as follows:

    Custom xcodebuild arguments:


    rest are all with default setting

  11. Could you tell us what version of xcode does clang-scanbuild plugin support
    or what all features of jenkins are available for iOS

  12. This comment has been removed by the author.

  13. thank you for your share, it work well !

  14. Thanks Steve!
    Amazing how a ~4 year old post continues to prove so useful.
    Any thoughts on why different slaves can behave differently, with apparently the same configurations?

    1. This happens _only_ when there are multiple login accounts on a machine.

  15. Simple and very helpfull! thanks

  16. Thank you so much steve.. It was very helpful!!

  17. These steps are not helping me as well getting the following error still --- Need help

    No profile matching 'XXXXXXXXX' found: Xcode couldn't find a profile matching 'XXXXXXXXX'. Install the profile (by dragging and dropping it onto Xcode's dock item) or select a different one in the General tab of the target editor.
    Code signing is required for product type 'Application' in SDK 'iOS 10.0'

  18. Thank you so much Steve.. It was very helpful!!