Python in iOS App

Discussion in 'iOS Programming' started by nashyo, Jan 13, 2013.

  1. nashyo macrumors 6502


    Oct 1, 2010
    How would you integrate a language like Python into an App for iOS?

    I realise there is an option to 'create a new empty file' in XCode. I assume you can just paste in some Python directly into an empty file and include some how?

    Or am I being naive?
  2. ArtOfWarfare, Jan 13, 2013
    Last edited: Jan 13, 2013

    ArtOfWarfare macrumors G3


    Nov 26, 2007
    I'm pretty sure you're being naive in thinking Python code will run on iOS.

    I think you're going about this the wrong way... what is your goal here?

    Simply learning a language to learn a language doesn't sound like a good use of time. You could go ahead and learn brainf*ck, but it has no practical use, so why bother (unless you're fond of tearing your hair out while debugging code.)

    IE, the reason I learned the portions of C++ that I know are so that I could use OGRE 3D, a 3D graphics engine, on my iOS and OS X apps.

    The only languages you're allowed to use to write iOS apps are:


    Obj-C is a perfect superset of C... all valid C code is valid Obj-C code.
    Most valid C code is also valid C++ code.
    C++ adds in a bunch of different features from what Obj-C adds... and then they share some features in common.
    Obj-C++ is a merge of Obj-C and C++... I'm not exactly sure how it works, but my understanding is that all Obj-C and/or C++ code is valid Obj-C++ code.


    I just remembered this. You can also make a web app. You can use HTML 5, CSS 3, and Javascript (IDK what version) to make one of those.
  3. Albright macrumors regular

    Aug 23, 2011
    Well, it would be possible to put Python in an iOS app, actually, or other non-C-related languages like Lua or Ruby. I've never done anything like that, but from what I understand, it would basically involve including and compiling the Python runtime code - that is, the C code for the application which reads and interprets the Python code - in your app, then writing an Objective-C wrapper which throws a Python file into that runtime and reads whatever the results may be; either form standard output, or by directly accessing the memory structures and such that Python is using, if you need more complex integration. (This is basically what something like RubyMotion would be doing, but I couldn't find a Python equivalent after a quick search.)

    Eventually you can get to a point where, yes, you can just dump some Python code into a file and manipulate the behavior of your app through that, but yeah, starting from scratch, I'm afraid it's not going to be that easy.
  4. itsmrjon macrumors regular

    Jun 11, 2011
    Yes you can, there is an app called Pythonista that actually will build the Xcode project for you with the Python interpreter so you can write Python apps (using their framework).

    I'm not sure exactly how they do it, but it would be a great place to start looking.

    attached a SS to show the Python executing in the simulator

    Attached Files:

Share This Page