How to embed a python file in a SwiftUI app?

I am making an app in SwiftUI, but the backend code relies on python and cannot be converted to swift. How can I get the file to run?

There are two challenges here:

  • Swift can’t call Python directly (unlike, C, Objective-C, and C++).

  • The Python runtime is rather complex, and you have embed it within your app.

With regards the first, the baseline mechanism for doing this integration is for your Swift code to call the Python runtime directly. However, there are various libraries to make this easier. I’ve never used any of them, so I don’t have a specific recommendation. If you search the ’net for obvious terms, like “call Python from Swift”, you’ll find lots of resources in this space.

With regards embedding the Python runtime in an app, that presents its own challenges. However, lots of folks have done this. I recommend that you research this via Python’s support resources.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to embed a python file in a SwiftUI app?
 
 
Q