Calling python from Objective-C on IOS

305 views
Skip to first unread message

Some One

unread,
Jul 21, 2021, 4:06:16 PM7/21/21
to Kivy users support
Hello,

I have existing objective-C app for IOS. I want to add some image processing functions  that are much easier to write in python, so i decided to see if there is a way to  link python interpreter directly into my objective-c IOS app, and then call python  to run different scripts to do image processing.

Anybody knows if this is possible using kivy, or any other way?

Thanks

Elliot Garbus

unread,
Jul 21, 2021, 6:20:31 PM7/21/21
to kivy-...@googlegroups.com

This question has nothing to do with kivy.

 

I would recommend only use one environment for the app (Do it all in Python, or do it all in objective-C) .  There are a number of restrictions on IOS that will make using the 2 environments together challenging. 

 

If you want to embed python in your app read: https://docs.python.org/3/extending/embedding.html#embedding-python-in-another-application

Your use case is not the typical use case for embedding python.  Python is often embedded to provide a scripting language for an application.  Blender, for example, uses python as it’s scripting language.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/3ffecbe6-8326-4103-b538-13f0be8bf1fdn%40googlegroups.com.

 

Some One

unread,
Jul 21, 2021, 7:15:41 PM7/21/21
to Kivy users support
The reason is i have existing IOS objective-c app, to do image processing would take a lot of low-level objective-c code which  would easier be done using python. There are only a few python libraries i could find that can run on IOS pivy is one, and there are some others im researching also, but this seems the post popular, so i decide to ask the question in here.

It may not be the typical use case, but thats my situation right now, either use python, or spend months using objective-c to do the same thing that python can do in a few lines of code.

I was wondering if there was a way to embed python into objective C, so that i can call it from objective-c when i want it to do something, where the result would be just one app that has everything in it.

Elliot Garbus

unread,
Jul 21, 2021, 8:09:20 PM7/21/21
to kivy-...@googlegroups.com

I understand.  My recommendation is you convert your objective-c code to python/kivy do your image processing in python and build your app.

I don’t see a clean way to combine these multiple environments (objective + Python) given the limitations of IOS. 

In a desktop OS, you could create a sperate process (one running python for example) and call into that process from another language.  I do not believe this kind of capability is available under IOS.

Additionally, the tools for packaging kivy/python apps for IOS and Android are complex and designed for packaging a python app into an executable for the target environment.  They are not designed to take a python program and create an object you can call from objective-c.

 

You need to decide the most resource effective way to get to your desired end goal. 

Reply all
Reply to author
Forward
0 new messages