I'm currently working on a macOS application using Xcode and Swift, and I want to incorporate some features that require a third-party Python package. I've been trying to figure out how to bundle Python with these packages into my app for the past couple of weeks, but I haven't had any success. If anyone has experience with this or knows if it's even possible, I'd really appreciate your insights!
1 Answer
One approach is to create your Python components as a standalone app and offer an API to your main macOS app—this could be through stdin/stdout, sockets, or HTTP. Then you can use tools like PyInstaller or Nuitka to package your Python application along with its libraries into an executable. You would include this in your main app bundle and start it as a subprocess, allowing interaction via the API. It's a clean way to keep your app organized without having to directly embed Python code.
I like the idea of creating a standalone Python app and using an API. It seems like a solid backup plan if embedding doesn’t work out. Can you explain more about using PyInstaller to bundle everything up? What are the steps involved?