Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
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?
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,560
6,059
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:

C
Obj-C
C++
Obj-C++

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.

Edit:

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.
 
Last edited:

Albright

macrumors regular
Aug 23, 2011
130
299
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.
 

itsmrjon

macrumors regular
Jun 11, 2011
122
0
Chicago
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. http://omz-software.com/pythonista/

----------
edit...
attached a SS to show the Python executing in the simulator
 

Attachments

  • Screen Shot 2013-01-14 at 3.18.00 PM.png
    Screen Shot 2013-01-14 at 3.18.00 PM.png
    217.2 KB · Views: 650
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.