Reputation: 26168
I'm trying to run a simple Python script every time I build my app in Xcode. The Python script is called test.py
and resides in my project folder as a sibling to my .xcodeproj
file.
I think I followed the instructions in the Stack Overflow post
Is this possible to run a python script before Xcode doing compiling? but I am receiving the error Shell Script Invocation Error: Command /bin/sh failed with exit code 1
I installed Python 3.5.2, but when I type python -V
into Terminal I get Python 2.7.10
. However, when I type python3 -V
into Terminal I get Python 3.6.0
. Typing which python
into Terminal returns /usr/bin/python
, while typing which python3
into Terminal returns /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
.
Following the instructions in Xcode: Running a script before every build that modifies source code directly I also moved the Run Script section in Build Phases to before Compile Sources.
This is what my Run Script section looks like. I have a strong feeling that the fix is annoyingly simple but have been unsuccessful trying to figure out what I am doing wrong / what search terms to use in Google or Stack Overflow.
And of course, let me know what other info I can provide to help debug.
EDIT: I have no preference for which version of Python I use other than that it allows me to run a Python script each time I build. I just installed Python 3.5.2 because I thought it might help.
EDIT 2: Tried deleting Derived Data (even though I am using Xcode 8.2.1) in addition to Clean
(Cmd-Shift-K) and Cleaning Build Folder...
(Cmd-Shift-Alt-K) and still no luck.
Upvotes: 3
Views: 1705
Reputation: 26168
I managed to get this working by using /bin/sh
as my shell and python test.py
as my script.
Upvotes: 3
Reputation: 22942
In the "Shell" input, try this path: '/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5'
Upvotes: 0