Xcode is a native IDE (Integrated Development Environment) of Apple made for the development of apps for the Apple ecosystem (macOS, iOS, tvOS, watchOS, and visionOS), which primarily use Swift and Objective-C languages for this purpose. However, this app is not made specifically for Python, but if you are an Xcode fan and do not want to switch to any other Python IDE, then there is a way to run Python in Xcode. Let us discuss in this article.
Running Python in Xcode
To run Python while using Xcode for Windows, follow the given steps.
- Install the latest version of Python from the official website- “python.org” on your Mac. After opening the Python website, go to the “Download” section and click on “Download.”

- To install Python, open the downloaded file and click on “Continue” to agree to all the requirements. Now, enter your Mac password in the last step, and click on “Install Software.” After that, Python will be installed successfully on your Mac.
- After that, open Xcode and make sure that you have the latest version of Xcode installed on your Mac (since an outdated version makes your data vulnerable and can lead to several runtime or compilation errors).
- Click on “Create New Project” and go to the “Other” select “External Build System” in it, and tap on “Next.”

- Now give a “Product Name” of your choice.
- Open the terminal app and give the command “which python3” to locate Python on your Mac. And put that path in the “Build Tool” section and click on “Next.”

- After that, choose the location for creating your project’s folder and then click on the “Create” button. Here, we select “Desktop” to place our project’s folder.
- Now we have to make a new Python file. To make a new file, go to File (top left corner) > New > File from Template and then go to the macOS > Other and choose “Empty” then tap on “Next.”

- After that, give a name to your file as per your choice, make sure to add the “.py” extension to the name of your file and then click on the “Create” button.

- Go to the target preset at the top corner of the screen, in our case, it is “Run Python.” And then click on “Edit Scheme.”

- Now go to Run > Info in “Edit Scheme” and click on “Executable”, then select “Other” in it. After that, tap “Command + Shift + G” then a box will pop up, enter the “/usr/bin/python3” path that we found through Terminal and then after selecting “python3,” click on “Choose.”

- Uncheck the “Debug Executable.”
- Go to the “Arguments” tab and click on the “Plus” icon in the “Arguments Passed On Launch” section, and enter your Python file name in it with the “.py” extension.
- Now go to the “Options” tab and check the “Use custom working directory” in the “Working Directory” section, and then add your Xcode project to it. After that, click on “Close” present at the bottom corner of the screen.

- The setup process has been completed; now it’s time to test and run your Python program in Xcode. Write some code, and after writing, click on the “Play” button present at the top left corner of the screen to run this code.

Additional Tips
- While naming your Python files, make sure that there is no space between words and the name ends with “.py.”
- Ensure that you have pasted the correct path in “Build Tool.”
Make sure to follow this process, step by step, without skipping any steps- even minute mistakes can lead to multiple errors. If you get any error, then you should recheck all the steps or repeat the whole process.