This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
What is special about the Xcode template?
donnieh last edited by
What is special about the Xcode template from omz that allows Xcode to run python and Pythonista's modules? So you can run any language in Xcode?
It something special installed in the Xcode template that allows python to run?
ccc last edited by
Think of it like layers of an onion... Your python script is at the center, then comes Pythonista, then comes the iOS simulator, then comes the Mac OSX, finally comes the Unix spinoff Darwin that the Mac OS runs on top of. Each of these
runtimesdepend on the runtimes beneath them running properly.
If you picture it like Python functions:
If any outer function crashes or does not run then the inner functions will either crash or not run. When thought about this way, XCode is not really (directly) running your Python script. Instead, XCode is launching the iOS simulator runtime which is launching the Pythonista runtime which in turn runs your Python script.
If you want to run Python scripts natively on the Mac then I would highly recommend the free version of PyCharm https://www.jetbrains.com/pycharm instead of trying to use XCode. However, you will no longer have access to Pythonista-specific modules such as ui, scene, location, motion, etc.
kollivier last edited by
If you are asking what the purpose of the Xcode template is when we already have the Pythonista app, the purpose of the Xcode template is to allow you to create standalone iOS apps using Python that don't require the end user to have Pythonista installed.
The Xcode template includes an iOS version of the Python runtime and an Objective-C function that runs the Python script you specify when the app starts. I'd say it's like the iOS equivalent of py2app or py2exe.
donnieh last edited by
@ccc thanks for the visual. I appreciate the detail. I am just surprised Xcode supports python. phcharm looks good, but will Idle work too for Mac?
@kollivier I understand the purpose of the template as you mentioned, a stand alone app. The Pythonista template including the "Python runtime and an Objective-C function that runs the Python script you specify" when the app starts is what I now realize what makes it different than a normal Xcode project.
ccc last edited by
If you open the
Terminalapp on your Mac, you can type
python -Vand you will see that Apple provides you a Python interpreter built into Mac OS X. XCode does allow you edit Python files (with syntax highlighting) but I do not know of any way to run Python scripts directly from within XCode. (Perhaps I am missing something). In general, Apple wants to keep developers focused on coding in ObjectveC and Swift but it does include python, ruby, osa, etc. on every box.
Yes, Idle does run on the Mac but if PyCharm were a car then Idle would be a wheelbarrow. You can use it but it is not really the way to get around town. Another way to go would be TextWrangler which is free in the Mac OSX AppStore and it lets you run your Python scripts directly out of the editor. If you really want to explore Python development on Mac OSX then start to get to know the homebrew package manager http://brew.sh
dgelessus last edited by
Perl, Python and Ruby are probably only included with OS X because some other Apple software uses a
rbscript at some point. At least the Apple Pythons include some OS X-specific APIs, no idea if that is also the case for Perl and Ruby.
IDLE isn't the greatest on OS X. Of course it has exactly the same functionality as on Windows, Linux or any other OS, but the Tkinter GUI does not play nicely with OS X at all. Positioning the text cursor with the mouse doesn't work properly half of the time. IDLE also lacks many customization options, such as what line endings to use, whether to keep trailing whitespace (or indentation on whitespace-only lines), whether or not to use hard tabs, etc. It feels like they try to enforce PEP 8 plus some other arbitrary formatting standards on your code without leaving you any choice.
(Yes, I personally prefer to use hard tabs and to leave indentation on blank lines. Hard tabs because smaller file size and unambiguity, and indentation on blank lines because it makes inserting code there much easier.)
briarfox last edited by
If you need a GUI for OSX I'd try out Kivy, Would love to see kivy implemented in pythonista, would make cross platform devv so much easier.