
Show HN: Python on iOS Native Apps - jventura
https://github.com/joaoventura/pybridge-ios
======
jventura
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...](https://github.com/joaoventura/pybridge-
ios/blob/master/docs/references.md).

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....](https://play.google.com/store/apps/details?id=com.flatangle.charts)),
which uses the same technique but for android
([https://github.com/joaoventura/pybridge](https://github.com/joaoventura/pybridge))

~~~
vaxman
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.

~~~
jventura
A simple strategy is to include only the pyc or pyo files inside a zip file,
and it will continue to work as well..

------
Osmium
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...](https://www.tensorflow.org/swift/tutorials/python_interoperability)

~~~
wool_gather
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.

~~~
saagarjha
Note that Apple will not let you put an application built with an alternative
toolchain on the App Store.

------
serial_dev
Similar (?) project where you can write Python code and create apps for iOS,
and Android (and others) [https://beeware.org/](https://beeware.org/)

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

~~~
jventura
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.

------
thealistra
Is this even allowed by Apple guidelines? Isn’t it the same rule that banned
Flash?

------
appybois
Do you know how much using python and the framework adds to the binary size?

~~~
miohtama
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](https://news.ycombinator.com/item?id=23338227)

~~~
jventura
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..

~~~
jakear
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.

~~~
jventura
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.. :)

~~~
jakear
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.

