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.
Xcode also uses instances of the Copy Files build phase to embed frameworks, app extensions, app clips, and other content inside your bundle. You use these build phases to copy other project files into a bundle. For example, you might copy templates for new documents into your app's bundle.
Click the Build Phases tab. Click the Add button (+), then choose “New Run Script Phase” from the pop-up menu. Click the disclosure triangle for the newly added Run Script phase. In the Shell text field, enter your script code.
1 Select xcodeproj file of you project -> Select Target -> Select Build Phases -> Click on plus button (upper left corner) -> Select New Run Script Phase. 2If you want to run a script while it is being installed on the device then please check a little checkbox just below the script box.
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
chmod 755 yourScriptName.sh
Put /bin/sh
in front of the path to the script name.
/bin/sh /Users/superman/Documents/Projects/SomeProject/scriptname.sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With