Linking python as external build tool in Xcode 7 El Capitan
Solution 1:
trying run Python 2.7.11 on Xcode 7.2 on OS X 10.11.2; I could not select 'python' under "Edit Scheme" > "Info" > "Executable" It was grayed out. I do not know what SIP means, but I got it to work by right-clicking the grayed out 'python' under usr/local/bin in the window and selecting "Quick Look" A box opened and I closed it and 'python' was now selectable and ran the file like a champ!
Solution 2:
My system is OS X 10.11 El Capitan with SIP enabled, with Xcode 7.2.1, and the following solution work for me.
The solution briefly: for your executable, select the Python installed in your system, which resides in:
Python.framework/Versions/ (3.x or 2.7) /Python
The location of Python.framework depends on which distribution of Python you're using. Most often it can be found in /Library/Frameworks
.
More comprehensive directions below.
Edit your Xcode scheme:
- Select Product > Scheme > Edit Scheme
- Run > Info > Executable > Other
- Press Cmd(⌘)+Shift+G and type in the place where your Python executables are installed.
- Select "Python" executable file.
Now, the place where the actual executables varies, depending on which Python distribution you chose to install. None of those, to my knowledge, place anything but symlinks to /usr/local/bin
or /opt/local/bin
. Below, I'll provide directions to finding your Python executable file.
MacPython
This is the version from the official Python website, and it resides in /Library/Frameworks/Python.framework
.
ActiveState ActivePython
Installs to the same directory as MacPython.
MacPorts
MacPorts installs its python to /opt/local/Library/Frameworks/Python.framework
.
HomeBrew
HomeBrew has two possible locations for your Python.framework, because unlike any other distribution, HomeBrew installs them separately.
- python2 in
/usr/local/Cellar/python
- python3 in
/usr/local/Cellar/python3
Inside either of them, you'll find Frameworks/Python.framework
.
All distributions
Inside any Python.framework
, you'll want to open a folder named Versions
. Inside, you'll find folders corresponding to Python versions installed on your system. Open whichever one you want to use, and inside You'll find an executable named Python
. You're done!
Solution 3:
I know this was posted a loooong time ago, but i ran into the same issue just now, and thought i would share my findings.
This solution worked for me.
- Close Xcode.
- Browse to you project library.
- Right click the project .xcodeproj file and choose 'Show Package Contents'
- Find the project .xcscheme file and open it in a editor.
- Find the PathRunnable tag, and set the FilePath to "/usr/local/bin/python3"
- Save the file and open the project again.
This way you can use brew install python3
to install your preferred Python for Xcode.