- Open Xcode 4.
- In the menu bar, click "File" → "New" → "New Project…".
- Select "Other" under "Mac OS X".
- Select "External Build System" and click "Next".
- Enter the product name.
- For the "Build Tool" field, type in /usr/local/bin/python3 for Python 3 or /usr/bin/python for Python 2 and then click "Next".
- Choose where to save it and click "Create".
- In the menu bar, click "File" → "New" → "New File…".
- Select "Other" under "Mac OS X".
- Select "Empty" and click "Next".
- Navigate to the project folder (it will not work, otherwise), enter the name of the Python file (include the ".py" extension), and click "Save".
- In the menu bar, click "Product" → "Edit Scheme…".
- Click "Run" in the left column.
- In the "Info" tab, click the "Executable" field and then click "Other…".
- Navigate to the executable from Step 6. You may need to use ⇧⌘G to type in the directory if it is hidden.
- Select the executable and click "Choose".
- For the "Debugger" field, select "None".
- In the "Arguments" tab, click the "Base Expansions On" field and select the target you created earlier.
- Click the "+" icon under "Arguments Passed On Launch". You may have to expand that section by clicking on the triangle pointing to the right.
- Type in $(SOURCE_ROOT)/ and then the name of the Python file you want to test. Remember, the Python program must be in the project folder. Otherwise, you will have to type out the full path here.
- Click "OK".
- Start coding.
原始來源 http://stackoverflow.com/questions/5276967/python-in-xcode-4/5438416#5438416:
沒有留言:
張貼留言