Embed python in to iOS (iphone) app written in Objective-C/Swift/C/C++ (whatever language i can compile in Xcode and bridge to iOS) [closed]
Asked Answered
D

1

12

I Do Not Intend To Put The Project On The App Store

  • Short Question - is there any up-to-date PyObjC tutorial for embedding python scripts into an iOS app written in Objective-C and/or swift? If not if there any up-to-date method for achieving the same goal?

  • Background: I want to run a bunch python scripts in an objective-c ios app. I have tried a couple of things:

    1. I have tried using the python.framework, but i get a "could not build Python module" error. After googling for help, I realized that python.framework does not work on iOS - Run python scripts in iOS app

    2. PyObjC - For the sake of experimenting, I managed to get the generated *.plugin working on OS X. I followed this tutorial - https://pythonhosted.org/pyobjc/tutorials/embedded.html Using the same method on iOS, it fails to compile

Dogfish answered 12/8, 2015 at 16:25 Comment(4)
The project is just for fun and not meant to go in the app store?Mononucleosis
I dont intend to put the project in the app store. I just want to use it as a demo for the python engineDogfish
Important to note that, or you'll get a ton of people saying, it isn't allowed.Mononucleosis
Thanks Cameron, I just updated the questionDogfish
D
18

If anyone is ever interested in calling python from swift, here is some helpful material I found(used) -

Most of it is for Objective-c, but if you need to use swift you can easily just create an ObjC-Swift bridge (super-super easy) - Lookup the apple docs

I managed to get the first two methods working on an OS X app, but I got some architecture errors for iOS(not important). I've pushed the project aside for now, I have a ton I need to get done.

Hope this will be helpful for anyone interested :-)

Dogfish answered 14/8, 2015 at 17:21 Comment(2)
Hi, I have exact case what you have described in question. Did you find solution to make it work in iOS project? If so, can you please guide me? I want to use this library in my project github.com/secnot/rectpackPlank
Any updates on this? If you have a git with your progress that would be awesome. I've been thinking about converting python to C and loading that into iOS. I haven't had any luck with the methods you've listedPeale

© 2022 - 2024 — McMap. All rights reserved.