kivy / kivy-ios

Toolchain for compiling Python / Kivy / other libraries for iOS
https://kivy.org/docs/guide/packaging-ios.html
MIT License
758 stars 238 forks source link

Support arm64 simulator on Apple Silicon hardware #751

Closed dlewandaDK closed 10 months ago

dlewandaDK commented 1 year ago

Is your feature request related to a problem? Please describe. I am trying to build my app on Xcode 14.1 but I am required to run Xcode in Rosetta mode due to my kivy-ios-generated static library (.a file) not being able to link against an arm64 simulator SDK. I have confirmed that the issue is that the library's contents are of an older style as described in this post using otool -l -arch arm64. The output contains a field LC_VERSION_MIN_IPHONEOS, but according to that link it should be LC_BUILD_VERSION with an explicit platform field. The specific error is "building for iOS simulator, but linking in object file built for iOS"

I am unable to figure out how to modify it accordingly to use the new version.

Describe the solution you'd like I'd like my static libraries generated by Kivy to follow this new format so that I can get out of Rosetta mode when running on my Apple Silicon hardware to get the maximum performance and modern system support.

Describe alternatives you've considered We currently run in Rosetta mode, but as Apple is moving fast away from Intel machines, it's not clear how long Rosetta 2 support will extend.

Additional context This is similar to #740.

dlewandaDK commented 1 year ago

Thank you for picking this up last week @misl6. I had an opportunity to pose a question regarding what controls this format in Apple's Q&A Slack space today, and this was the response from their engineer:

This is controlled by the deployment target of the static library (.a). It is likely being built with an older OS specified as its deployment target, and that causes LC_VERSION_MIN_IPHONEOS to be used instead of LC_BUILD_VERSION which is the newer replacement load command. I would recommend either raising the deployment target of that static library target if you maintain that library, or else contact the library maintainer and request they offer an updated library built with a newer deployment target.

I hope that helps identify and isolate the issue!

mressler commented 1 year ago

I've had the same issue. Thanks for picking it up @misl6!

akshayaurora commented 1 year ago

This issue should now be defunct, kivy-ios runs in native mode on Apple silicon. It runs on emulators too without any issue thanks to all the work by @misl6

dlewandaDK commented 1 year ago

Thanks for the update @akshayaurora. Can you point to the commit(s) that accomplished the change? I would love to understand what changed so I can learn more about how kivy evolves under the covers?

dlewandaDK commented 1 year ago

@misl6 and @akshayaurora - it looks like Xcode 14.3 will deprecate Rosetta support, so it would be great to get confirmation that there's a code change in this repo that supports this change. The expected change to bump up the minimum version of iOS from 9 to something newer doesn't appear to be present in the main branch, unless I'm missing something.

misl6 commented 1 year ago

Hi @dlewandaDK !

We support builds on Apple Silicon hardware, without the aid of Rosetta since tag 1.3.0 (PR: https://github.com/kivy/kivy-ios/pull/660).

But, we still build for the x86_64 Simulator on Apple Silicon, and instead we should build for the arm64-simulator on Apple Silicon hardware.

You're right, but AFAIK XCode doesn't need to be executed with Rosetta in order to have x86_64 Simulator support.

The good news is that I'm currently working on Python 3.10 support. After that, a re-work of the Simulator builds is scheduled.

dlewandaDK commented 1 year ago

Hi @misl6, thanks for responding and reopening this issue. We agree that we can build on Apple Silicon just fine, but the only limitation is not being able to run on the arm64 simulator when running outside Rosetta mode. The irony is now that it lets you build for My Mac (designed for iPhone) we can run natively on the arm64 Apple Silicon MacBook Pro just not in the simulator. As such this isn't a showstopper for us, but I am glad to hear it's on your radar to get it working such that we will be able to use the full set of Apple developer tools running as close to the metal as possible. Happy to help test it out when you're ready!

misl6 commented 1 year ago

Hi @dlewandaDK !

I've just opened a PR which is targeting this issue (https://github.com/kivy/kivy-ios/pull/778). It's still in WIP, and the CI will likely fail on some (outdated) recipes, but some testing on your side will be super-helpful to address potential issues faster.

(Feel free to ping me on Discord)

dlewandaDK commented 1 year ago

Hi @misl6, thanks so much for the update. We are currently in the throes of a big deliverable on our side such that I can't promise exactly when, but I'll try to get someone on our side looking at your changes ASAP. Looking forward to seeing it through!

dlewandaDK commented 1 year ago

Hi @misl6, thanks so much for the update. We are currently in the throes of a big deliverable on our side such that I can't promise exactly when, but I'll try to get someone on our side looking at your changes ASAP. Looking forward to seeing it through!

@misl6 we launched our new app (that is depending on kivy-ios!) and now finally have time to jump in and try the branch from the PR you posted last month. Anything we should know as we jump in and pull your branch from your fork? Anything we can focus on?

dlewandaDK commented 10 months ago

Thank you @misl6 for your hard work and dedication here! We look forward to trying out the latest changes ASAP. We had issues with moving our Python code from 3.9 to 3.10, but we've recently solved that and should be able to update to the latest Kivy very soon 🙌 🎉