51

Updating from Xcode 10.0 beta 2 to Xcode 10.0 beta 3 I now get this error at build time for an iOS project:

sourcekit: [1:connection-event-handler:10499: 0.0000] Connection interruptsourcekit: [1:updateSemanticEditorDelay:10499: 0.0007] disabling semantic editor for 10 secondssourcekit: [1:pingService:10499: 0.0007] pinging servicesourcekitten: connection to SourceKitService restored!
Connection interrupted
Never call this for file that sourcekitd fails.: file File+Cache.swift, line 127
/Users/Coeur/Library/Developer/Xcode/DerivedData/My-App-eloayqptodupvfhbyegtkncnhcpu/Build/Intermediates.noindex/My-App.build/UAT-iphonesimulator/My-App-Debug.build/Script-379156A71D62F5C100574D04.sh: line 2: 34382 Abort trap: 6 "${PODS_ROOT}/SwiftLint/swiftlint"
Command PhaseScriptExecution failed with a nonzero exit code

Swift 4.1
CocoaPods 1.5.3
SwiftLint 0.26.0

Cœur
  • 32,421
  • 21
  • 173
  • 232
  • Transient note for Googlers: There seems to be a [regression in CocoaPods](https://github.com/CocoaPods/CocoaPods/issues/8000) that will be fixed in 1.6.x. For me, the error went away after switching to the 1.6.0 beta (and updating all dependencies; not sure if that had anything to do with it). – Raphael Oct 05 '18 at 10:26
  • @Raphael You're writing about something unrelated to my question. I've now clarified the title to disambiguate it. And actually, someone already posted the error log you're referring to at https://stackoverflow.com/questions/52234957/xcode-10-command-phasescriptexecution-failed-with-a-nonzero-exit-code-expanded – Cœur Oct 05 '18 at 10:46
  • I ended up here after googling a very similar error, so I figured a comment here would be helpful. I hadn't found the other post, which is indeed the better fit. Thanks! – Raphael Oct 05 '18 at 11:52
  • In my case, I forgot to add `pod 'SwiftLint'` to my podfile while doing `pod install`. – Mohammad Zaid Pathan Feb 06 '20 at 11:10

20 Answers20

86

Its because of Keychain Access.

  • Open Keychain Access
  • Right Click Login Tab
  • Lock Keychain Login
  • Right Click Login Tab again
  • Unlock Keychain Login

and problem solved :)

Mehmet AKYOL
  • 1,666
  • 1
  • 11
  • 20
  • And why would you still be using SwiftLint 0.26.0 or older in year 2019? The issue is long time solved by simply updating SwiftLint! – Cœur Jan 29 '19 at 07:56
  • I don't use Swift or SwiftLint at all, because I use Obj-C. This answer solved my problem on Xcode 9+ and iOS 10+. – AndaluZ Feb 18 '19 at 10:32
  • @AndaluZ it's practically impossible to have a SwiftLint error message without using it. – Cœur Feb 26 '19 at 12:38
  • @Cœur I had this error "Command PhaseScriptExecution failed with a nonzero exit code", it wasn't based on Swift related stuff. btw this solution is also not specific to Swift related stuff, it has more to do with Xcode build tools I guess. – AndaluZ Feb 27 '19 at 08:56
  • Thanks. This is my solution because I am working on the push notification certification signing. – littlecodefarmer758 Mar 01 '19 at 03:02
  • This did not work for me check out: https://stackoverflow.com/questions/54937724/command-phasescriptexecution-failed-with-a-nonzero-exit-code-i –  Mar 01 '19 at 04:34
31

It seems to be an issue with the SwiftLint 0.26.0 script when using Xcode 10.0 beta 3 or newer.

Cause

It seems related to SwiftLint #2276, itself related to SourceKitten 0.21.0, fixed in SourceKitten 0.21.1 and SwiftLint Master.

Solution

Update to SwiftLint 0.27.0 or newer:

pod 'SwiftLint', '~> 0.27'

(and run pod update SwiftLint)

Community
  • 1
  • 1
Cœur
  • 32,421
  • 21
  • 173
  • 232
27

Some Framework or SDK require Code Signing.

I done code signing and resolved the problem for me.enter image description here

Ashvin A
  • 6,683
  • 3
  • 27
  • 45
23

The pod that I was using was not updated for Xcode 10, so the solution that worked for me was to remove Cocoapods from my project and then installed again (the project was created on Xcode 9).

To remove it, the easiest way is:

$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean

After that, install the pods again.

ChavirA
  • 695
  • 8
  • 17
  • 1
    This broke my code, since the libraries I use, not all of them are compatible with the newer version of pod. I had to recover my code from time machine. – zeeshan Dec 30 '18 at 11:08
13

I just restarted my Macbook and it worked.

shim
  • 7,170
  • 10
  • 62
  • 95
Mahmut Şahin
  • 484
  • 5
  • 12
5

For me adding arm64 architecture in "Build Setting -> valid architectures" resolved the issue.

user6456083
  • 71
  • 2
  • 1
3

I had an authentication process (outside of Xcode) running in the background which seemed to be causing this issue for me. I had the keychain dialog up asking for my password. Solution was to restart the machine.

shim
  • 7,170
  • 10
  • 62
  • 95
Kilmazing
  • 517
  • 7
  • 14
2

Solution worked for me

I deleted all pod generated files and folders as listed below

  • Podfile.lock
  • Pods folder
  • ProjectName.xcworkspace

Again install pod for this project.

Now open .xcworkspace. Build and run...

pallavi
  • 443
  • 6
  • 13
1

It may cause the iOS 13 version. My error is to look at below

Assignment/Pods-Assignment-frameworks.sh: eval: line 131: unexpected EOF while looking for matching `''
Command PhaseScriptExecution failed with a nonzero exit code

Pods -> Targets Support Files -> Pods-AppName -> Pods-AppName-frameworks.sh. Just commented particular line 131

 # eval "$code_sign_cmd"

then clean and run

Sreekanth G
  • 492
  • 4
  • 10
0

This issue resolves for me when I wait and let the project complete indexing before I do anything!

neha
  • 6,007
  • 11
  • 43
  • 76
0

Restarting Xcode 10.1 fixed it for me; arose while updating Cocoapods ('RxSwift').

shim
  • 7,170
  • 10
  • 62
  • 95
Varun Parakh
  • 192
  • 1
  • 3
  • 9
0

If the directory where your project is has blank spaces that problem occurs To solve that problem add double quotes(""). For example:

"$(SRCROOT)/my framework/path"

0

In my case, Apple development certificate got expires.

To verify open Keychain -> My certificates -> check developer certificate is valid or not, If certificate is not valid then follow the below steps.

  • Open your apple developer account and create a new development certificate
  • Download and add it in your keychain.
  • Go to profiles and open your existing development profile and add the newly created certificate.
  • Download the fresh profile and install it.

Hope this helps you too.

Shubham
  • 1,154
  • 2
  • 10
  • 24
0

I had this issue on my ionic4 app after I have used cocoapods. My issue was that in Targets->Build Phases->Embed Pods Frameworks, I had a wrong path to Pods-MyApp-frameworks.sh script correcting that path solved the issue for me. Its because most of the time $PODS_ROOT variable doesn't set after installing pods

Awais Nasir
  • 679
  • 10
  • 14
0

For me, there seems to be an issue with the swiftlint script. It was initially this, Which was what was in the doc as of the time of installation

else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

I resolve the issue by modifying it to

if swiftlint
then
echo "swiftlint installed"
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

Not sure, this may be due to my XCode version(10.3)

heeleeaz
  • 172
  • 1
  • 2
  • 13
0

I resolve the issue by rewrite the .sh file. Xcode 10 with Swift 3.

1.rename problem.sh file and command+A then command+C.
2.vi *problem*.sh and command+V.
3.:wq! to save the new file.

Then everything will be ok.

If not ok, chmod a+x *problem*.sh and try again.

Cœur
  • 32,421
  • 21
  • 173
  • 232
iwpz
  • 154
  • 9
0

Only the following helped me.

  1. Delete Podfile.lock
  2. run pod install
  3. Optional - update SwiftLint version
Garnik
  • 403
  • 6
  • 20
0

For me it was an issue with swiftlint. This happens when ever there are serious errors, for example forced unwrapping that swift lint validates.

The actual SwiftLint errors are not shown. Instead this “Command PhaseScriptExecution failed with a nonzero exit code” error is shown. After a bit struggle, I figured out that if your project's directory name or any its hierarchy folders have an apostrophe 's , then actual swiftlint errors or warnings are not shown even after including the runscript for it.

So I just had to rename my folders.

For example:

User -> Dave's Projects -> Git -> ProjectName

should be changed to

User -> Daves Projects -> Git -> ProjectName

This will show you errors or warnings. You can then fix the errors and hopefully the concerned error will also be fixed.

Amrit Sidhu
  • 1,663
  • 1
  • 14
  • 31
-1

I had a new Macbook and got this error when trying to archive. I forgot to install cocopods in the new machine, so I did, then restarted the computer and restarted Xcode and it worked.

fullmoon
  • 6,463
  • 3
  • 34
  • 52
-1

If you're getting

dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib

and a red

Command PhaseScriptExecution failed with a nonzero exit code

You should install the specific version of libreadline that you need

brew install readline
brew list --versions readline
brew switch readline 0.0.0
ehacinom
  • 5,256
  • 3
  • 32
  • 56