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

Community
  • 1
  • 1
Shaun
  • 804
  • 2
  • 8
  • 16

1 Answers1

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 :-)

Shaun
  • 804
  • 2
  • 8
  • 16
  • 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 https://github.com/secnot/rectpack – thavasidurai Jul 28 '17 at 10:59
  • 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 listed – smoosh911 May 19 '18 at 02:20