0

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.
daredevil1234
  • 1,303
  • 1
  • 10
  • 34

2 Answers2

1

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.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • yeah, but I can't just add a complete path: there are multiple devs who work on this. A valid path on my machine is not a valid path on some else's machine. – daredevil1234 May 10 '22 at 00:04
  • additionally, this issue didn't occur with the update to Monteray, i had been on that for weeks. It happened after I updated from Xcode 13.1 to 13.3, and even then it was after a couple weeks. it was sudden. one day xcode made me install additional tools awhile after updating to 13.3 and suddenly this built script now fails – daredevil1234 May 10 '22 at 00:07
0

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.

daredevil1234
  • 1,303
  • 1
  • 10
  • 34