Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this possible to run a python script before Xcode doing compiling?

Tags:

xcode

I am using Xcode to develop application. But I include some test files, and I would like to keep a reference timestamp while I do compiling. Is this possible for me to do some scripting before I start compiling the programme? Of course, I can manually run the script before I compiling, but I would like to do it in one step, and recommend? Thanks.

like image 940
DNB5brims Avatar asked Nov 14 '13 22:11

DNB5brims


People also ask

Can you run Python code in Xcode?

I started wondering if it was possible to use Xcode to code python, the answers "Yes", but it requires a little setting up to do.

Is it possible to run Python on iOS?

Python for iOS and iPadOSPyto also provides a complete development environment for running Python 3 including many third-party libraries and system integration on an iPad or iPhone.

Can you use Python and Swift together?

Swift For TensorFlow supports Python interoperability. You can import Python modules from Swift, call Python functions, and convert values between Swift and Python.


2 Answers

You need to add a build phase. Go to the project file, Build Phases, click Editor on the tool bar menu, add Build Phase, Add Run Script... You can select and drag the script to put it before/after anything.

Then the shell should be /usr/bin/python, then you can type in your script below. The script will run every time you build.

like image 84
mergesort Avatar answered Sep 22 '22 17:09

mergesort


  1. Project File -> Build Phases -> Add Build Phase (Bottom right) -> Add Run Script
  2. Drag the new build phase into the correct order
  3. Under Shell -> /bin/sh
  4. Then in the text box, fill up something like "/usr/bin/python /Users/me/test.py"
like image 25
NachoChip Avatar answered Sep 24 '22 17:09

NachoChip