filmov
tv
How to Use Python in XCode

Показать описание
Learn how to use python in Xcode. We will teach you how to create a new xcode project, specify bin directory, edit the scheme and eventually view the output.
In this tutorial, we will teach you how to use Python in Xcode.
In this tutorial, you'd have to have python installed on your macbook. We are assuming that you have already downloaded and installed Python in Mac.
Step 1 -- Create a new Xcode Project
Follow this step by step guide to learn how to use python using Xcode. So let's start off by first launching the Xcode application.
Once the welcome screen appears, click on the "Create a new Xcode Project" option to get started.
Step 2 -- Choose a template
Now you would be required to choose a template for the new project. For the purpose of this tutorial, we will choose the "external Build System" template available in the "Other" section.
Step 3 -- Enter product name & build tool
In the next step, just give your project a name and do remember to specify the "bin" directory of python in the Build tool field at the bottom. To see where the python's bin directory is present, just open up the terminal application, type "which python" and hit enter. You can copy the complete path from there only.
Moving on, you would be required to specify the location where the project is to be saved. For the purpose of this tutorial, we will save it on the desktop.
Step 4 -- Edit Scheme
Now we need to prepare a specific scheme that would allow a file, on which we will be working on later, to be passed to the Python Interpreter.
For that, we will need open the Product menu, go to Scheme and then click on the Edit Scheme option.
Step 5 -- Locate python executable file
Make sure you're in the Run section and over there, open up the Info tab. Now since we need to connect to the python binary, we will open the executable menu and click on the other option.
Now all you have to do is locate and select the python executable file and that's it.
After that, do remember to choose the "none" option for Debugger.
Step 6 -- Type file name
Next, open up the Arguments tab and just type the filename with the .py extension under the "Arguments passed on launch" section.
Step 7 -- Use custom working directory
Once you are done, open up the options tab and select the "use Custom Working Directory" option. Over here, we will specify the same location where we saved the project earlier.
Step 8 -- Create a new empty template
With that done, we are basically finished with editing the schemes. Now let's create a new empty template to work on.
Here, specify the same file name in the save as field, which we specified in the Arguments tab.
Do remember to tick on the checkbox next to the target file over there and then click on the Create button.
Step 9 -- View output
Now we will simply print the text on the screen. For that, we will use the print keyword along with the message that is to be printed.
Now let's run the code and see how the output appears. In this manner, you can use python. And in the image below, you can see that the text we included in quotes is appearing on the screen as the output.
In this manner, you can use python in Xcode.
In this tutorial, we will teach you how to use Python in Xcode.
In this tutorial, you'd have to have python installed on your macbook. We are assuming that you have already downloaded and installed Python in Mac.
Step 1 -- Create a new Xcode Project
Follow this step by step guide to learn how to use python using Xcode. So let's start off by first launching the Xcode application.
Once the welcome screen appears, click on the "Create a new Xcode Project" option to get started.
Step 2 -- Choose a template
Now you would be required to choose a template for the new project. For the purpose of this tutorial, we will choose the "external Build System" template available in the "Other" section.
Step 3 -- Enter product name & build tool
In the next step, just give your project a name and do remember to specify the "bin" directory of python in the Build tool field at the bottom. To see where the python's bin directory is present, just open up the terminal application, type "which python" and hit enter. You can copy the complete path from there only.
Moving on, you would be required to specify the location where the project is to be saved. For the purpose of this tutorial, we will save it on the desktop.
Step 4 -- Edit Scheme
Now we need to prepare a specific scheme that would allow a file, on which we will be working on later, to be passed to the Python Interpreter.
For that, we will need open the Product menu, go to Scheme and then click on the Edit Scheme option.
Step 5 -- Locate python executable file
Make sure you're in the Run section and over there, open up the Info tab. Now since we need to connect to the python binary, we will open the executable menu and click on the other option.
Now all you have to do is locate and select the python executable file and that's it.
After that, do remember to choose the "none" option for Debugger.
Step 6 -- Type file name
Next, open up the Arguments tab and just type the filename with the .py extension under the "Arguments passed on launch" section.
Step 7 -- Use custom working directory
Once you are done, open up the options tab and select the "use Custom Working Directory" option. Over here, we will specify the same location where we saved the project earlier.
Step 8 -- Create a new empty template
With that done, we are basically finished with editing the schemes. Now let's create a new empty template to work on.
Here, specify the same file name in the save as field, which we specified in the Arguments tab.
Do remember to tick on the checkbox next to the target file over there and then click on the Create button.
Step 9 -- View output
Now we will simply print the text on the screen. For that, we will use the print keyword along with the message that is to be printed.
Now let's run the code and see how the output appears. In this manner, you can use python. And in the image below, you can see that the text we included in quotes is appearing on the screen as the output.
In this manner, you can use python in Xcode.
Комментарии