How To Build & Run Python Scripts with Xcode – Python programming is needed for this tutorial to start the minimum necessary level of Python programming required.
Today, I’m going to use XCODE
Now check out the step by step guide with proper instruction and high-quality snapshots:
How To Build & Run Python Scripts with Xcode ( UPDATED 2022 )
Contents
Step 1. Install Python 3.5
However, you can download the latest version using this download link:
https://www.python.org/downloads/release/python-352/
Step 2. Locate Python3
I’m going to use tcsh, therefore where python3 reports /usr/local/bin/python3. It will be similar to you, just check out the equivalent for the bash.
Step 3. Create a XCode project
File > New > Project > Cross-platform > External Build System > Next.
Now you need to enter your name (e.g. Python), the path from Step 2 into the ‘Build Tool’ line. Click on the Next.
Now you need to click on the Create.
Step 4. Create a Python file
Choose File > New, select macOS > Other > Empty. Click Next.
Now you are at the top of the folder. Now you need to enter the name as per your choice; I have decided Work.py Make sure the “add to target Python” box is checked. Click Create.
Step 5. Edit your Run Scheme
The XCode default would be selected the Run scheme.
Click and hold on to the Python target in the jump bar. Now here you need to select Edit.
The Run scheme displays, with the Info tab selection as per the screen showing.
Step 6. Choose the Executable
Now the central and challenging part started, and don’t use the symbolic link at /usr/local/bin/python3. I will explain it later.
In the Info tab. Now you need to select “Other” from the Executable pop-up list. Wherein the main box dialogue appears.
Now you need to return to the terminal. Type: open /usr/local/bin. Select python3 and control-click/right-click. Now you need to select the Show Original. It will be showing the name of python3.5. Now Sigh.
Now you need to drag python3.5 onto the file dialog and then you need to click Choose if you’re allowed to. Now you need to check XCode: create a hard link and then drag the link onto the dialog.
% ln python3.5 python35
Now you need to be renaming the file.
Finally, uncheck “Debug executable”. Make sure to debug the Python language yourself as it will not work automatically.
Step 7. Add Launch Arguments
Now you need to click on the Arguments tab. Click + under “Arguments Passed on Launch” and type $(SRCROOT)/ followed by the name of the Python file you created in Step 4.
Step 8. Test it out.
Now you need to click on the Close to dismiss the scheme editor. Enter a program and run it:
So, now you have the experience of entering into Python with a Swift background. It looks similar and easy for Python developers, who have already worked on it.
Read More:
- Xcode for iPad Pro
- Designing Your Own Project Templates in Xcode
- Xcode Couldn’t Find Any iOS App Development Provisioning Profiles Matching
Now you can share this useful article as well as the tutorial for Xcode Developers, who would love to test this technique. As it is the more important and most popular application available in the market to do coding work. You can bookmark this page for a more updated article as per the latest Application updates. How To Build & Run Python Scripts with Xcode
Related Tags – How To Build & Run Python Scripts with Xcode