How to embed a Python interpreter in an iOS app - presented by Łukasz Langa
Channel: EuroPython Conference
Date: 2022-10-19

EuroPython 2022 - How to embed a Python interpreter in an iOS app - presented by Łukasz Langa

[Liffey A on 2022-07-15]


Come see how you can make a native mobile app that embeds Python 3.10 to allow users to script app behavior. It's allowed by Apple but is currently underutilized by the app makers. Add superpowers to your iPhone app with Python!

Native mobile applications have many advantages over mobile websites or apps made with cross-platform toolkits. They will use less battery, allow for richer graphics, more consistent UI behavior, and enable more functionality through device-specific APIs. Wouldn't it be great to have access to all this from Python?

In this talk, we'll marry a native iOS app written in Swift with an embedded Python 3.10 interpreter to allow users to customize what the application is doing. We'll go through the entire process of:

- embedding Python from source;
- building it into the Swift mobile app in Xcode;
- adding a few pre-compiled third-party libraries like numpy and Pillow to broaden the scope of what the user can do;
- running the resulting app on an iPhone 13;
- modifying the app behavior at runtime thanks to our new Python superpowers!

Knowledge of Swift is not required for attendees of this talk. However, it will be needed later if you're willing to embed Python in an iPhone app. Embedding Python doesn't really let you make an app without knowing Swift. Don't fret though! It's pretty easy to get a hang of Swift when you're fluent in Python.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License http://creativecommons.org/licenses/by-nc-sa/4.0/