Sample project demonstrating Python on iOS, using native native UI (Apple UIKit).
Grab prebuilt framework from: https://github.com/dimaqq/Python-Apple-support/releases/download/3.6.1-b1/Python-3.6-iOS-support.b1.tar.gz
Note:
- branch corresponds to Python version (i.e. use 3.5)
- package corresponds to target device (e.g. iOS for iPhone)
Unpack it at at top level of repository, so that it looks like this:
⋊> ~/i/pios on master ◦ ls -la
total 24
drwxr-xr-x 14 dima staff 476 18 Feb 08:11 .
drwxr-xr-x 4 dima staff 136 17 Feb 19:06 ..
drwxr-xr-x 16 dima staff 544 24 Feb 13:19 .git
-rw-r--r-- 1 dima staff 485 8 Feb 21:14 .gitignore
drwxr-xr-x@ 5 dima staff 170 5 Sep 10:33 BZip2.framework
drwxr-xr-x@ 5 dima staff 170 16 Feb 18:21 Dishuhu Malala Arkuyaya.xcodeproj
drwxr-xr-x@ 5 dima staff 170 5 Sep 10:46 OpenSSL.framework
drwxr-xr-x@ 6 dima staff 204 5 Sep 11:01 Python.framework
-rw-r--r-- 1 dima staff 839 18 Feb 08:11 README.md
drwxr-xr-x@ 5 dima staff 170 5 Sep 10:37 XZ.framework
drwxr-xr-x 4 dima staff 136 7 Feb 22:06 app
drwxr-xr-x 8 dima staff 272 18 Feb 12:12 app_packages
drwxr-xr-x 7 dima staff 238 8 Feb 21:05 dimark
-rw-r--r--@ 1 dima staff 32 5 Sep 11:01 support.version
Start XCode with open Dishuhu\ Malala\ Arkuyaya.xcodeproj
, select target device, run with ⌘R. Simulator should show up and start this app.
For example, to use trunk Objective C bindings, do:
pip install -t app_packages https://github.com/pybee/rubicon-objc/archive/master.zip --upgrade
I'll try to show equivalent calls for Swift, Objective-C and Python.
Instantiate some class, that is create an object. new
is same as alloc+init
if no arguments are used.
# let x = UIViewController()
x = ObjCClass("UIViewController").new()
# UIViewController *x = [[UIViewController alloc] init];
x = ObjCClass("UIViewController").alloc().init()
Same with arguments
# let x = UINavigationController(rootViewController: root)
# INavigationController *x = [[UINavigationController alloc] initWithRootViewController: root];
x = ObjCClass("UINavigationController").alloc().initWithRootViewController_(root)
Colors
# UIColor.blue()
# [UIColor blueColor]
ObjCClass("UIColor").blueColor()