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.

77 comments:

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

    ReplyDelete
  2. 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.

    ReplyDelete
  3. Thanks, you saved my time

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

    ReplyDelete
  5. Here is a better solution: http://stackoverflow.com/questions/9626447/unable-to-sign-ios-builds-with-jenkins?rq=1

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

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

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

    ReplyDelete
  9. 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/XXX.app/ResourceRules.plist /var/folders/rj/cc6d38nn53v6tk8y4jn7ghkr0000gp/T/42RbMszHQX/Payload/XXX.app 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:

    CODE_SIGN_RESOURCE_RULES_PATH=/Users/mitul/Public/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/ResourceRules.plist

    rest are all with default setting

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

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. You Are the Best!!!! Thanx a lot.

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

    ReplyDelete
  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?

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

      Delete
  15. Simple and very helpfull! thanks

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

    ReplyDelete
  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'

    ReplyDelete
    Replies
    1. facing same issue ..... please help me badly stuck here https://stackoverflow.com/questions/46580092/jenkins-build-failed-xcode-couldnt-find-a-provisioning-profile-matching

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

    ReplyDelete
  19. With reference to point 2 ) 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.

    In my case I have /Users/Jenkins/Library/MobileDevice/Provisioning .....so should I move profile to ../Shared/..

    ReplyDelete
  20. Excellent and helpful post… I am so glad to left comment on this. This has been a so interesting ..I appreciate your effort..
    Iphone app development uk | ios app development uk

    ReplyDelete
  21. Thanks, it worked.
    QUESTION: How to create .ipa file using jenkins?

    ReplyDelete
  22. It 's amazing article and useful for developers
    iOS Online Course

    ReplyDelete
  23. Hey Steve Zhang, Thanks you saved the Day!!!

    ReplyDelete
  24. Hi,

    Thanks for this saved my time. But now I am getting:

    Signing certificate is invalid. Signing certificate "iPhone Developer:----", serial number "----", is not valid for code signing. It may have been revoked or expired.

    although it is valid as I can create build in xcode using the same

    ReplyDelete
  25. That's an excellent idea, keep up the good work!

    ReplyDelete
  26. Thank you for saving my life and our team life.

    ReplyDelete
  27. Setiap permainan judi online, ada panduan bermain agar mampu memenangkan permainan. Tanpa terkecuali dengan judi dominoqq online
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terpercaya
    hobiqq
    paito warna terlengkap
    bocoran sgp

    ReplyDelete
  28. CROWNQQ I AGEN BANDARQ I BANDARQ ONLINE I ADUQ ONLINE I DOMINOQQ TERBAIK
    Yuk Buruan ikutan bermain di website CrownQQ

    Sekarang CROWNQQ Memiliki Game terbaru Dan Ternama loh...

    9 permainan :
    => Poker
    => Bandar Poker
    => Domino99
    => BandarQ
    => AduQ
    => Sakong
    => Capsa Susun
    => Bandar 66
    => Perang Baccarat (NEW GAME)

    => Bonus Refferal 20%
    => Bonus Turn Over 0,5%
    => Minimal Depo 20.000
    => Minimal WD 20.000
    => 100% Member Asli
    => Pelayanan DP & WD 24 jam
    => Livechat Kami 24 Jam Online
    => Bisa Dimainkan Di Hp Android0619679319
    => Di Layani Dengan 5 Bank Terbaik
    => 1 User ID 8 Permainan Menarik

    Ayo gabung sekarang juga hanya dengan
    mengklick Daftar CrownQQ

    Link Resmi CrownQQ:
    ratuajaib.com
    ratuajaib.net
    ratuajaib.org

    BACA JUGA BLOGSPORT KAMI:
    Agen BandarQ Terbaik
    Winner CrownQQ
    Daftar CrownQQ

    Info Lebih lanjut Kunjungi :
    WHATSAPP : +855882357563
    Line : CS CROWNQQ
    Facebook : CrownQQ Official

    ReplyDelete
  29. Jadi, PayPal ini merupakan salah satu sistem ataupun mekanisme pembayaran yang nantinya bisa dilakukan dengan secara on the web. Nah, kunjungi pulsa dengan paypal pada intinya PayPal tersebut adalah sebuah perusahaan yang memang menawarkan jasa transfer ataupun penerimaan uang melalui surat elektronik.

    ReplyDelete
  30. Microgaming telah memperkenalkan sekitar empat game baru yang unik dan inovatif setiap bulan. Salah satu elemen paling menarik dari permainan perusahaan adalah item bagus yang dikenal sebagai Viper pokerpelangi
    98toto

    ReplyDelete
  31. ayo tunggu apalagi website terbaik dan terpercaya win rate 98%

    qqslot
    qq288
    judi slot

    ReplyDelete
  32. fee feel to visit my site https://idnslotjoker.com

    ReplyDelete
  33. Your blog is very nice and has sets of the fantastic piece of information. Thanks for sharing with us. If you face any technical issue or error, visit:

    Quickbooks customer service

    ReplyDelete
  34. Türkiye'nin en güvenilir takipçi satış platformu : takipçi satın al

    İnstagram takipçi mi almak istiyorsun sadece tıkla : instagram takipçi satın al

    Tiktokta fenomen olmaya hazır mısın işte seçenekler : tiktok takipçi satın al

    2 . takipçi satın alma linki : takipçi satın al

    3 . takipçi satın alma linki : takipçi satın al

    ReplyDelete
  35. Hey! Fabulous post. It is the best thing that I have read on the internet today. Moreover, if you need instant support for QuickBooks Error, visit at QuickBooks Customer Service Our team is always ready to help and support their clients.

    ReplyDelete
  36. Este blog é muito informativo Estou feliz em postar minha opinião neste blog. Acabou sendo muito útil para mim e tenho certeza para todos os comentaristas aqui! Este é um bom artigo. Lendo isso eu achei muito informativo. 카지노사이트
    Obrigado por dedicar seu tempo e esforço para escrever este artigo. Mais uma vez, percebi que estava perdendo muito tempo lendo e comentando.
    Por favor, visite meu site e deixe um comentário. ajude meu site

    ReplyDelete
  37. Congratulations on your article, it was very helpful and successful. e5fd5b7180cbac9477db5789cf1efc20
    website kurma
    website kurma
    numara onay

    ReplyDelete
  38. Thank you for your explanation, very good content. cbd4294a0dd47a17af2befaf51e91634
    define dedektörü

    ReplyDelete