What permissions are required for "Run Script" during a build phase?
Asked Answered
B

4

36

In the "Run Script" build phase of my project, everything works if I type in the script into the text box for "run script" in build phases.

But to make editing / diffing etc easier, I thought I would save the script as a file as part of my project, and just fill in the path in the text box instead:

Eg: I paste the following path in the text box.

/Users/superman/Documents/Projects/SomeProject/scriptname.sh

But when I try to build this, I get a "Permission Denied" message.

What can I do to fix this? If I cut/paste the actual code, then it just "works". My user account is an administrator account. No one else uses my machine.

Bemire answered 24/3, 2012 at 10:24 Comment(0)
B
83

You can simplify your Xcode project file a little further and not require the "bin/sh " in front of the script name.

To avoid this, you need to turn on "execute" permissions for users (Xcode in this case) of the file.

Steps

  • Go into terminal
  • Navigate to where your script is
  • run chmod 755 yourScriptName.sh
Bullnose answered 22/10, 2013 at 15:33 Comment(3)
I think this answer should be marked as correct because it is addressing the core of the issue. A runnable script file should be marked as executable.Merriment
simple but effective :)Tarsia
That saved my time!People
L
39

Put /bin/sh in front of the path to the script name.

/bin/sh /Users/superman/Documents/Projects/SomeProject/scriptname.sh
Lighterage answered 24/4, 2012 at 19:34 Comment(0)
C
15

Just use

chmod u+x nameofscript.sh

Thats it .

Cordage answered 9/7, 2015 at 9:26 Comment(0)
O
1

Simple Steps:

  1. Go to the <your_Script>.sh via cd <Your_Path_To_.sh_File>
  2. Run chmod +x <your_file>.sh

Thats it

Opulent answered 28/10, 2019 at 4:20 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.