Permission Denied error in Xcode 10 preventing Build...Command PhaseScriptExecution failed with a nonzero exit code

James LCQ picture James LCQ · Dec 14, 2018 · Viewed 13.6k times · Source

I'm unable to Build/Archive my project due to an error:

Permission denied
Command PhaseScriptExecution failed with a nonzero exit code

I have tried correcting keychain login as advised by other answers, but it hasn't worked. Please could someone help? Most likely a rookie mistake but means I cannot even simulate my app.

Further details on the error:

PhaseScriptExecution Copy\ Pods\ Resources 

/Users/james/Library/Developer/Xcode/DerivedData/trials-fseuxkwjlleukxdxyfgdrujhdwuy/Build/Intermediates.noindex/trials.build/Debug-iphonesimulator/trials.build/Script-8DEE2FC97BFA0D6E636019C4.sh (in target: trials)
    cd /Users/james/pCloud\ Drive/3.\ NeuroRecovery\ Ltd/4.\ Products/3.\ NIHR\ Trial\ NHS/v1.0\ -\ Initial\ App/1.\ App\ Delivery/3.\ Source\ Code/1.\ iOS/trials
    /bin/sh -c /Users/james/Library/Developer/Xcode/DerivedData/trials-fseuxkwjlleukxdxyfgdrujhdwuy/Build/Intermediates.noindex/trials.build/Debug-iphonesimulator/trials.build/Script-8DEE2FC97BFA0D6E636019C4.sh

/Users/james/Library/Developer/Xcode/DerivedData/trials-fseuxkwjlleukxdxyfgdrujhdwuy/Build/Intermediates.noindex/trials.build/Debug-iphonesimulator/trials.build/Script-8DEE2FC97BFA0D6E636019C4.sh: line 2: /Users/james/pCloud Drive/3. NeuroRecovery Ltd/4. Products/3. NIHR Trial NHS/v1.0 - Initial App/1. App Delivery/3. Source Code/1. iOS/trials/Pods/Target Support Files/Pods-trials/Pods-trials-resources.sh: Permission denied
Command PhaseScriptExecution failed with a nonzero exit code

Edit 17th Dec: thank you @geno-chen & @fantini I have checked & can report the following:

  1. Did you install Cocoapods with sudo: Yes.

  2. I checked the permissions of the files using ls -lh and had the following: -rw-r--r-- 1 james staff 159B 25 Mar 2015 Podfile -rw-r--r-- 1 james staff 1.2K 25 Mar 2015 Podfile.lock drwxr-xr-x 11 james staff 352B 17 Dec 14:03 Pods drwxr-xr-x 52 james staff 1.6K 17 Dec 14:03 trials drwxr-xr-x@ 5 james staff 160B 17 Dec 14:03 trials.xcodeproj drwxr-xr-x@ 5 james staff 160B 17 Dec 14:03 trials.xcworkspace drwxr-xr-x 4 james staff 128B 17 Dec 14:03 trialsTests

  3. I used chmod to modify permissions of the podfiles as below: -rwxr-xr-x 1 james staff 159B 25 Mar 2015 Podfile -rwxr-xr-x 1 james staff 1.2K 25 Mar 2015 Podfile.lock drwxr-xr-x 11 james staff 352B 17 Dec 14:03 Pods drwxr-xr-x 52 james staff 1.6K 17 Dec 14:03 trials drwxr-xr-x@ 5 james staff 160B 17 Dec 14:03 trials.xcodeproj drwxr-xr-x@ 5 james staff 160B 17 Dec 14:03 trials.xcworkspace drwxr-xr-x 4 james staff 128B 17 Dec 14:03 trialsTests

I then Cleaned my Build Folder, restarted but still have the same error.

Answer

Sawsan picture Sawsan · Jan 29, 2019

I fixed the permission problem by running the following command.

chmod +x "Path to .sh"

Please replace ProjectName with your project name and username with your username

chmod +x /Users/username/Documents/ProjectName/Pods/Target\ Support\ Files/Pods-ProjectName/Pods-ProjectName-frameworks.sh

You can get the path from your xcode project as explained by step 1 to 3