skip to Main Content

I have a build phase that calls some python scripts.

This has been working fine for well over 2 years, but after recently updating to Xcode 13.3 it now fails.

Build phase script calling python with a .py file

the error I started receiving is:

/Users/me/Library/Developer/Xcode/DerivedData/MyApp-fsowouspdsdjjzfmlfafizjbkcae/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/Script-9002D8C42166BC850081D43D.sh: line 6: python: command not found
Command PhaseScriptExecution failed with a nonzero exit code

At a glance, it looks like xcode is attempting to run the script on the simulator instead of running in the local project directory.

python –version:
Python 3.8.3

I am wondering if there is some new configuration that I am unaware of for new xcode versions?

EDIT:

  • when i run the the lines in the script in my terminal, they run just fine.

2

Answers


  1. Chosen as BEST ANSWER

    So, Xcode seems to bundles its' own versions of python and python 3. It does not use the system version, so changes to Monteray 12.3 would not affect this.
    Since that is the case, the correct solution is changing python to python3 since it looks like an Xcode update dropped python2.7 to parallel the OS dropping it later. I had to also update my python file to ensure compatibility.


  2. You have installed Python 3 somehow (brew, perhaps), and it is in your PATH. That is why, when you say python, it is found.

    But that same Python is not in Xcode’s PATH! And it never has been. You’ve never noticed this, and you’ve never needed to notice it, because Xcode has always used the system Python, which was located in /SystemLibraryFrameworks. You and Xcode were probably using different Python versions (the system version stopped at 2.7), but this didn’t matter.

    But now (Monterey 12.3), it isn’t. There is now no Python in Xcode’s PATH. Thus, when your script says python plain and simple, it isn’t found. You can fix this by using a complete path in your scripts that specifies where your Python is. You can find this out by saying which python.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search