30

When I updated my mac to macOS Sierra 10.12.1 time of running application on real device significantly increased. "Run custom script 'Embed Pods Frameworks'" and "Copy Swift standard libraries" take more then 30 minutes to build.

Do someone face the same issue?

psu
  • 304
  • 3
  • 10
  • I'm having the same problem and I'm not able to find the solution. I will let you know if I discover what is the problem – kikettas Oct 26 '16 at 10:28
  • 1
    Someone here suggested to create a new user: http://stackoverflow.com/q/39934254/2491738. Haven't tried it myself though.. – ken Oct 26 '16 at 13:22
  • @ken yes, I have just tested it and it is a little bit faster. I will use this temporary user account while Apple decides to fix it... Thanks! – kikettas Oct 26 '16 at 15:32
  • Just tested my app on different computer, without new macOS update - everything works fast and fine, so I think that the user is not a problem, but I will try with new Apple user... – psu Oct 26 '16 at 15:39
  • On my second mac, after updated Sierra and used new GM Xcode, everything is builded normally. – psu Oct 26 '16 at 17:26

4 Answers4

32

Check your keychain. After updating to Sierra to 10.12.1, I had over 500 copies one of my certificates, and a few others were duplicated a few hundred times.

I removed all the duplicates and kept just one of each, and my code signing time went from 30 seconds per framework down to about 1 second per.

I don't know how or why the certificates were duplicated, but the timing of the issue suggests it was due to updating Sierra.

Troy
  • 5,319
  • 1
  • 35
  • 41
  • 1
    It was that! Thank you @Troy – psu Oct 28 '16 at 06:11
  • 3
    Deleting duplicate keychains does not works for me.. Still take 1~2 minutes to code sign frameworks for cocoapods when building to real device. – Johnny Oct 31 '16 at 04:28
  • @Johnny Are you experiencing 1-2 minutes per framework, or 1-2 minutes for all frameworks? If the latter, how many frameworks do you have? – Troy Oct 31 '16 at 06:02
  • @Troy For all frameworks, total 45 libraries in my podfile. I've posted similar question on stackoverflow: http://stackoverflow.com/questions/40281040/cocoapods-embed-pod-frameworks-took-long-time-to-execute Seems like other developers are experiencing this issue. Also tried the latest beta cocoapods feature for parallelize code signing: https://github.com/CocoaPods/CocoaPods/pull/6088 Still no luck :( – Johnny Oct 31 '16 at 07:04
  • @Johnny I see code signing taking a second or two per framework, so 1-2 minutes matches my experience given your 45 libraries. Speeding up code signing would be great, but I'm not sure it's possible. CocoaPods may be able to change the way they package the frameworks or may be able to "cache" the code signing results better. – Troy Oct 31 '16 at 18:31
  • 1
    @Troy Found a alternative solution, I've posted as an answer below, perhaps you can give it a try! :) – Johnny Nov 01 '16 at 04:02
  • It did speed up my compile time. I was being driven crazy – zirinisp Nov 16 '16 at 09:53
  • This was the answer for me, too! Just one certificate duplicated over a hundred times. – bcherry Mar 24 '17 at 18:39
23

2017-03-23 Update

You can skip installing the beta version of CocoaPods, because the COCOAPODS_PARALLEL_CODE_SIGN flag is also evaluated in the current release build.

Original Answer

Found an alternative solution, not best, but at least it's speeding up. It works (for me)

Cocoapods released a new beta version few days ago.

Which allows parallel code signing when running the embed framework script (https://github.com/CocoaPods/CocoaPods/pull/6088#issuecomment-257441733)

  1. Install the latest beta version

gem install cocoapods --pre

  1. Go to your Xcode target build settings and click the + icon at the top

enter image description here

  1. Set COCOAPODS_PARALLEL_CODE_SIGN to true

enter image description here

And enjoy the increased building speed!

Rafael Bugajewski
  • 1,702
  • 3
  • 22
  • 37
Johnny
  • 2,589
  • 2
  • 27
  • 34
  • Nice. This helps a lot as well. All 8 cores are all working on code signing at once now. Next step - speed up swift compile times! – Troy Nov 01 '16 at 17:35
  • Thank you! This issue was driving me nuts for a week and a half. – David Wong Nov 02 '16 at 00:37
  • how can you compare the timing? I can't see any – aelam Dec 14 '16 at 06:32
  • For those wondering, this is available since CocoaPods `v1.2.0`. To check - `pod --version` – Alexandre G Jul 03 '17 at 03:18
  • this worked for me : https://stackoverflow.com/questions/20649298/xcode-custom-shell-scripts-are-slowing-down-the-compiling-time?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Wojtek Dmyszewicz Mar 30 '18 at 14:34
17

If keychain looks good, but problems exists – check the preferences and remove all duplicates in this file: ~/Library/Preferences/com.apple.security.plist

For typical setup this file must contain only one record with login keychain reference.

Max Potapov
  • 1,267
  • 11
  • 17
0

All the above mentioned approaches didn't work for me. What helped a lot was resetting the System.keychain, which had 25 MB size. This speeded up build times up to 40% on our CI system.

Analyze

du -h /Library/Keychains/System.keychain
good: 60K
bad: 25MB

Reset

sudo systemkeychain -vfcC [password]

Attention: If you have important keys/certs/passwords stored in your System.keychain, you may want to export them before performing the reset and then reimport them on demand. This wasn't necessary for me. My new System.keychain has no content and building projects works absolutely fine.

Sven Driemecker
  • 3,421
  • 1
  • 20
  • 22