Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For context, I posted a video on Discord showing pygame-ce working as a native iOS app through Briefcase. This has detailed instructions about how it was done, and what iOS support looks like going forward.
How to build for iOS (no wheel)
While working on this build, I made a lot of super hacky changes to
meson.buildto create a proof of concept, and those files are part of this PR, as well as anios-crossbuild.txtfile which is passed into the--cross-fileargument. Lots of paths here are local paths on my machine (sorry), so you need to modify them to work for you. But basically:Python.frameworkis linked instead of usingpy.dependencyto get a dependency to Python itself. This framework can be found in a generated Briefcase iOS project, more on that below.py.extension_moduleare replaced withshared_module, and all references topyare removed.The build I made for the Discord video works by building the pygame-ce modules with
mesondirectly using--cross-fileto create iOS artifacts, instead of using meson-python to generate a wheel. I used the following commands:Once you have those built, you can create a fresh Briefcase app, specifying no framework (no Toga, etc) so there's no extra Python code in the way. You then create an Xcode project with
briefcase create iOS. At this point you can attach your downloaded SDL, SDL_image, SDL_ttf, and SDL_mixer Xcode projects to the generated Xcode project through their respective iOS instructions.Inside that Xcode project are two
app-packagesfolders, one foriphoneosand one foriphonesimulator. You can copysrc_pyinto both of these folders, then rename thempygameto make themimportable from your game's code. You can then copy your built C modules from Meson into this folder so thepygamemodule can see them on import (make sure they are namedbase.soinstead oflibbase.dylibor whatever Meson calls them on build, they need to be.sofor the custom xcode build phases).Finally, you need to change
main.mto get rid of the call toUIApplicationMain, since SDL calls this internally on init.Add your game code to your Briefcase app code in
__main__.py. Run the app on your device and it should work, I'm having issues with simulator builds but maybe you're smarter than me.What's probably needed for an iOS wheel
meson.buildto support the "ios" plat.