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.

65 comments:

  1. It works! THX a lot!!

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

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

    ReplyDelete
  4. Thanks, you saved my time

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

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

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

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

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

    ReplyDelete
  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/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
  11. Could you tell us what version of xcode does clang-scanbuild plugin support
    or what all features of jenkins are available for iOS

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

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

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

    ReplyDelete
  15. 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
  16. Simple and very helpfull! thanks

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

    ReplyDelete
  18. 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
  19. Thank you so much Steve.. It was very helpful!!

    ReplyDelete
  20. It was very helpful. Thanks.

    ReplyDelete
  21. 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
  22. 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
  23. Thanks, it worked.
    QUESTION: How to create .ipa file using jenkins?

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

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

    ReplyDelete
  26. 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
  27. That's an excellent idea, keep up the good work!

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

    ReplyDelete
  29. 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
  30. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    top angular js online training

    ReplyDelete
  31. NAGAQQ | AGEN BANDARQ | BANDARQ ONLINE | ADUQ ONLINE | DOMINOQQ TERBAIK

    Yang Merupakan Agen Bandarq, Domino 99, Dan Bandar Poker Online Terpercaya di asia hadir untuk anda semua dengan permainan permainan menarik dan bonus menarik untuk anda semua

    Bonus yang diberikan NagaQQ :
    * Bonus rollingan 0.5%,setiap senin di bagikannya
    * Bonus Refferal 10% + 10%,seumur hidup
    * Bonus Jackpot, yang dapat anda dapatkan dengan mudah
    * Minimal Depo 15.000
    * Minimal WD 20.000

    Memegang Gelar atau title sebagai AGEN BANDARQ Terbaik di masanya

    Games Yang di Hadirkan NagaQQ :
    * Poker Online
    * BandarQ
    * Domino99
    * Bandar Poker
    * Bandar66(NEW GAMES)

    Info Lebih lanjut Kunjungi :
    Website : NAGAQQ
    WHATSAPP : +855967014811
    Line : Cs_nagaQQ
    TELEGRAM :+855967014811

    BACA JUGA BLOGSPORT KAMI YANG LAIN:
    berita nagaqq/
    agen bandarq online/
    Kemenangan NagaQQ/

    ReplyDelete
  32. Tebakqq Situs PKV Games Terpercaya di Indonesia, ingin Bermain Games Dan Menang Banyak ?
    Segera Bergabung dan daftarkan diri anda di TebakQQ.

    8 Game Tersedia : Aduq , Bandar Poker, Bandarq, Capsa Susun, Domino99, Poker, Sakong, dan Bandar66

    Agen PKV Games
    Tebakqq
    Aduqq
    Bandarq
    Agen Dominoqq
    Situs Poker Uang Asli
    PKV Games apk android
    Daftar PKV Games
    Poker Depo Pulsa

    WA = +6281717806270
    Line = Tebakqq

    ReplyDelete
  33. Minimal deposit : 20rb
    Minimal Withdraw : 20rb
    Bonus Welcome 100% (bonus didepan)
    Bonus Next Deposit 20%
    Bonus Cashback 5%
    judi slot
    main slot
    slot online
    bandar slot
    cafeslots777
    cs7.asia
    casino indonesia
    indonesia casino online

    ReplyDelete
  34. Think about how often you click affordable SEO service There are some SEO experts who claim that your website can achieve the top rank in a month or two and then there are SEO experts who sit down with you and tell you the ins and outs of the entire process

    ReplyDelete
  35. TiketQQ Agen BandarQ Domino99 Bandar Poker dan Bandar66 Online Terbaik Di Asia

    Website paling ternama dan paling terpercaya di Asia ^^
    Sistem pelayanan 24 Jam Non-Stop bersama dengan CS Berpengalaman respon tercepat :)

    * Minimal DEPOSIT Rp 15.000,-
    * Minimal WITHDRAW Rp 15.000,-
    * Tersedia 9 game dalam 1 USER ID
    * Bonus TO 0,5% Setiap 5 hari
    * Bonus Refferal 20%
    * Proses Deposit & Withdraw PALING CEPAT
    * Sistem keamanan Terbaru & Terjamin
    * Poker Online Terpercaya
    * Live chat yang Responsive
    * Support lebih banyak bank LOKAL


    < Contact Us >
    Website : TiketQQ
    Facebook : TiketQQ
    Twitter : TiketQQ
    Instagram : TiketQQ
    LINE : Tiketqq
    WA : +855885063246
    Kontak : TiketQQ
    Blog : Cerita Dewasa

    Agen Judi Online Aman Dan Terpercaya TiketQQ

    ReplyDelete
  36. NAGAQQ | AGEN BANDARQ | BANDARQ ONLINE | ADUQ ONLINE | DOMINOQQ TERBAIK

    Yang Merupakan Agen Bandarq, Domino 99, Dan Bandar Poker Online Terpercaya di asia hadir untuk anda semua dengan permainan permainan menarik dan bonus menarik untuk anda semua

    Bonus yang diberikan NagaQQ :
    * Bonus rollingan 0.5%,setiap senin di bagikannya
    * Bonus Refferal 10% + 10%,seumur hidup
    * Bonus Jackpot, yang dapat anda dapatkan dengan mudah
    * Minimal Depo 15.000
    * Minimal WD 20.000

    Memegang Gelar atau title sebagai AGEN BANDARQ Terbaik di masanya

    Games Yang di Hadirkan NagaQQ :
    * Poker Online
    * BandarQ
    * Domino99
    * Bandar Poker
    * Bandar66
    * Sakong
    * Capsa Susun
    * AduQ
    * Perang Bacarrat (New Game)


    Info Lebih lanjut Kunjungi :
    Website : NAGAQQ
    Facebook : Facebook
    WHATSAPP : +855967014811
    Line : Cs_nagaQQ
    TELEGRAM :+855967014811

    BACA JUGA BLOGSPORT KAMI YANG LAIN:
    agen bandarq terbaik
    Winner NagaQQ
    Daftar NagaQQ

    ReplyDelete
  37. 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
  38. Idnplay
    IDN Poker88 | Situs Poker Deposit Pulsa | Agen Poker Terpercaya
    Agen Resmi Poker Idnplay Terpercaya dan resmi Lesensi ayok join sekarang juga untuk mendapatkan promo2 terbaik dari situs agen poker online sekarang juga !!

    ReplyDelete
  39. Selamat datang Di Situs Bandarq Terbaik Di Asia
    Rasakan sensasi serunya bermain di Situs Sahabatpoker

    Yukk.. Buruan Mainkan gamenya, Jadilah Pemenang dalam situs Faforite Anda
    Nikmati 9 Game Dengan Kualitas Terbaik Di Asia Hanya Di Situs Sahabatpoker :
    ✰ Poker
    ✰ Capsa susun
    ✰ DominoQ
    ✰ AduQ
    ✰ BandarQ
    ✰ Bandar poker
    ✰ Sakong Online
    ✰ Bandar66
    ✰ Perang Baccarat

    Promo Yang Berlaku Saat ini:
    => Bonus Refferal 15% + 5%
    => CashBack : 0,5% ( SETIAP MINGGU )
    => Minimal Depo Rp. 20.000,-
    => Minimal WD Rp. 20.000,-

    Pelayanan dan Sistem Di Situs Sahabatpoker :
    => 100% Member Asli
    => Pelayanan DP & WD 24 jam
    => Livechat Kami 24 Jam Online
    => Bisa Dimainkan Di Hp Android & IOS
    Kartu Bagus, Boleh Banding , Service Boleh Tanding !!!

    Akses Dengan Link Resmi :
    ✰ kotakslot.Org

    << Contact_Us >>
    ✰ Website : Sahabatpoker
    ✰ Instagram : sahabatpoker_official
    ✰ Twiter : Sahabatpoker_Official
    ✰ vk.c0m : Bandarq Terbaik Di Asia
    ✰ Line : sahabatpoker
    ✰ WhatsApp : Sahabatpoker
    ✰ INFO LENGKAP : Sahabatpoker_Official
    ✰ CERITA DEWASA : Cerita Dewasa

    ReplyDelete
  40. Idnplay
    IDN Poker88 | Situs Poker Deposit Pulsa | Agen Poker Terpercaya
    Agen Resmi Poker Idnplay Terpercaya dan resmi Lesensi ayok join sekarang juga untuk mendapatkan promo2 terbaik dari situs agen poker online sekarang juga !!

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