如何在IOS Swift应用中运行python程序

问题描述:

我是一名业余编码员,目前正在从事一个项目,我想知道您是否可以帮助我.

I’m an amateur coder working on a project right now, and I was wondering if you could help me.

基本上,我一直在研究一种特定的算法,发现使用Python可以更快地运行该算法.目的是让此Python代码在我的IOS应用程序中运行.我发现,Python解释器必须嵌入到Swift应用程序中才能执行此操作.但是,我还没有找到很多有用的文档或其他有关如何执行此操作的资料.您有什么建议或建议吗?

Basically, I’ve been doing a lot of research on a particular algorithm that I find runs much faster using Python. The goal is to get this Python code to run in my IOS application. What I’ve found is that the Python interpreter has to be embedded with the Swift application in order to do this. However, I haven’t found much useful documentation or other sources on how to do this. Do you have any suggestions or advice?

它看起来像您可以将Obj-C与Swift混合使用. 也就是说,我不确定您是否可以在iOS上实际执行此操作.

This tutorial seems to be fairly clear and easy to follow, and cover the necessary steps. Is there any chance you could share what the algorithm in question is? It might make more sense to use C - it looks like you can mix Obj-C with Swift. That said, I am not confident that you can actually do this on iOS.

首先,如果您的应用可能没有通过App Store审核,其中的Python可执行文件.苹果公司有自己的文档关于在OSX/Mac OS中嵌入Python应用程式,但不适用于iOS.

First of all, your app might not get through App Store review if it has an executable for Python in it. Apple has its own docs on embedding Python in OSX/Mac OS apps, but not for iOS.

此外,我认为甚至没有适用于iOS的Python官方可执行文件.我能想到或发现的最接近的东西是 Pythonista ,但我相信开发人员可以自己制作适用于iOS的Python版本.

Additionally, I don't think an official executable of Python for iOS even exists. The closest thing I could think of, or find, is Pythonista, but I believe the developer made their own version of Python for iOS.

看起来您可以导出 Pythonista代码到独立应用程序,尽管这很有用,无论天气如何,您都可以在iOS上执行此操作,我不知道.此外,该功能仅适用于Python2.希望这会有所帮助.

It looks like you can export Pythonista code to stand-alone apps, although how useful this is, and weather or not you can do this for iOS, I don't know. Additionally, that feature only works with Python2. Hope this helps.