I disabled SIP and removed System Python. Now Xcode won’t let me export apps

homebrewpythonxcode

I was pissed about having 20 different versions of Python on my Mac, so in an effort to clean it up I deleted every single instance of it. I disabled SIP and cleared out the system default one.

I then used Home-brew to install Python 3.7, Python 3.6, Python 2.7 (The versions I use).

However Xcode now gives an error when trying to export apps. It went from saying that it couldn't find python:

ipatool failed with an exception: #<RuntimeError: Couldn't locate python in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/bin /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec /Applications/Xcode.app/Contents/Developer/usr/bin /Applications/Xcode.app/Contents/Developer/usr/local/bin /Applications/Xcode.app/Contents/Developer/Tools /usr/bin /bin /usr/sbin /sbin>
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:180:in `locate_tool'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:160:in `unicode_equal?'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1882:in `block in MakeFileSystemNode'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1882:in `each'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1882:in `detect'

So I then copied over python 2.7 from home-brew into that directory and renamed it "python". I now get a different error, instead it says: The operation couldn’t be completed. No such file or directory. The error logs show nothing of importance.

Thank you.

Best Answer

The reason that version is protected by Sip is because it is essential for your system to work. Out of all the python you can remove, that one is not on the list. Normally python is relatively local, as in, everything lives in a single directory, but just replacing a couple files from the brew install to the OS install are not very likely to give you a working version of Python. The rest you must have installed yourself.

I'd say restore your MacOS and then use brew to install the additional versions you need. Even 2.7, as the OS one is not very good for anything but the OS itself. Same as you shouldn't pip install stuff globally but always in a virtual environment so that you don't get dependency crap with OS required items, or worse, OS items that fail to function due to broken dependencies.

Sorry, not the answer your looking for I'm sure, but the best I can give.