24

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.

James LCQ
  • 361
  • 1
  • 2
  • 4
  • It said "permission denied", then what is its permission? Maybe what you need is a `chmod +x`? – Geno Chen Dec 14 '18 at 16:07
  • Did you install Cocoapods with `sudo` did you run the install also with `sudo`? I'm thinking that your problem could be related with that, your user `james` doesn't have the permission to run that script (the one that was generated by Cocoapods). Go to the script location and list your files and permissions using `ls -lh`, add that to the question pls. – Fantini Dec 14 '18 at 16:08
  • added info above - thanks! – James LCQ Dec 17 '18 at 14:27

4 Answers4

58

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

double-beep
  • 5,031
  • 17
  • 33
  • 41
Sawsan
  • 1,096
  • 10
  • 20
  • 1
    How to give this permission permenently. In my case permission denied issues is coming each time when a new version of app is building. So I have to execute this command on every new build – Abhilash Shajan Nov 15 '19 at 12:17
  • 1
    This works! I suppose we need to re-grant the "executable" permission to the script if the pod is brought along with the project from the internet. By the way, we can use `ls -l "scriptPath"` to check if the permission is granted successfully. – Sam Aug 10 '22 at 13:32
33

I've tried @Sawsan method but get no luck even the file is already executable.

Here is the step how I solve it:

1.delete Podfile.lock

2.delete Pods directory

3.delete .xcworkspace file

4.Pod install again

that's it.

give it a try!

andrew54068
  • 1,326
  • 14
  • 29
17

I have to own a trial for this solution and I got a proper result.

Follow the step:

1) Open Terminal and set a project path

"pod deintegrate" command executes

2) Then after "pod install" command executes.

Priyank Gandhi
  • 626
  • 2
  • 8
  • 21
1

I solved by deleting the Pods folder that was committed to the repo.

rsc
  • 10,348
  • 5
  • 39
  • 36