23 comments

[ 2.5 ms ] story [ 59.0 ms ] thread
This project is a base for which to add a python interpreter to a swift iOS project. It allows us to call python functions and get the resulting string, and then use the result in swift code (to update native widgets, etc.)

As I'm a beginner in swift and iOS, I've documented all the process at https://github.com/joaoventura/pybridge-ios/blob/master/docs....

I hope this allows me to share all the Python code in my Android app (https://play.google.com/store/apps/details?id=com.flatangle....), which uses the same technique but for android (https://github.com/joaoventura/pybridge)

Will Apple approve apps that use this?
As long as there is no downloading, side-loading or user editing of python code in the app then Apple doesn't care.

There are limited exceptions for apps that teach programming, such as Pythonista.

There is a great disturbance in the Force --youngling Jedis are practicing their https://CircuitPython.org ways on https://circuitpython.org/board/particle_argon/ kits that have WiFi, BLE, NFC, TensorFlowLite local image/speech recognition and the ability to connect with all types and sizes of displays (ePaper to AMOLED, retinal projectors, touch, multitouch etc.) and interfaces to LTE (150/50Mbps) via https://www.dfrobot.com/product-1834.html as well as headphones, 3D-printed multi-module wearable cases, personal (airborne and ground based) drones, personal indicators and other interfaces that "New" Apple can't even begin to imagine in it's crummy foodcourt (where they fire their best for letting their little girls make a social media post that accidentally shows a prerelease build while hackers and 9to5Mac lay the entire next release bare for all the public). Time to port Blinka to iOS so that it can at least run this Future's apps using something like https://www.adafruit.com/product/2264
hah, my Karma literally went negative after that post on Friday (I don't post much so downvotes hurt) --probably wasn't the part about Python takin' over the game ;)

I have the same shirt as this poor guy... https://youtu.be/NeHFDf0zKs4

Are you okay with having your app's binaries string dumped by unknown parties where upon they find the underlying Python source code? Some basic encryption (or tokenization) would be better, since few would expect to go looking for it.
A simple strategy is to include only the pyc or pyo files inside a zip file, and it will continue to work as well..
Does anyone know the latest on the Swift-Python bridge from the TensorFlow team[0]? Is this still in development or usable for iOS apps?

[0] https://www.tensorflow.org/swift/tutorials/python_interopera...

I believe that you need the S4TF fork of the Swift compiler. It might be doable to swap it into Xcode as part of an alternate toolchain, but it's not likely to be easy.
Note that Apple will not let you put an application built with an alternative toolchain on the App Store.
Similar (?) project where you can write Python code and create apps for iOS, and Android (and others) https://beeware.org/

The talks from the author, Russell Keith-Magee, are very interesting, I learned a lot about how apps work.

also kivy ... https://kivy.org but both of those are more ux oriented, and with a different focus than this afaics.
As the sibling commenter said, that project and kivy are geared to write android and ios apps entirely in Python.

My approach is different. I have most of the business logic in Python (I share lots of code between a web app and an Android app I have) and write the UI logic in the platform’s native language. This means the apps are always using native UIs and use the platform toolchains, and I can use all tools available natively on the platform.

Do you know how much using python and the framework adds to the binary size?
I am not that worried about the binary size, but please see this discussion regarding loading times earlier today:

https://news.ycombinator.com/item?id=23338227

The answer to that post is mine, and i confirm that there’s some delay on start but on a moto g 2014 that i have it is ~3 seconds which is not much. By comparison, Outlook takes more than 10 seconds to start on my iphone 5s..
That’s pretty crazy re outlook. Takes about half a second on my 11. Clearly mine is newer, but over an order of magnitude is a lot.
Tested right now: 8 seconds of a white screen, then the blue logo appears for 2 seconds, and finally, at second 10, mails start to appear..

That is why I always test my apps on older hardware.. That, and because i only have old devices.. :)

I noticed that if I quit the app via the usual mechanism, it takes less than a second to load. However if I fully power cycle the device it’s closer to 5 seconds.
Libpython.a (and the others) have ~50MB and the standard library zip is ~4MB. But note that libpython and the others are fat libraries which includes X86 code that is only relevant for the iOS emulator and could be stripped eventually on release.
(comment deleted)
Is this even allowed by Apple guidelines? Isn’t it the same rule that banned Flash?