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.build
to create a proof of concept, and those files are part of this PR, as well as anios-crossbuild.txt
file which is passed into the--cross-file
argument. Lots of paths here are local paths on my machine (sorry), so you need to modify them to work for you. But basically:Python.framework
is linked instead of usingpy.dependency
to get a dependency to Python itself. This framework can be found in a generated Briefcase iOS project, more on that below.py.extension_module
are replaced withshared_module
, and all references topy
are removed.The build I made for the Discord video works by building the pygame-ce modules with
meson
directly using--cross-file
to 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-packages
folders, one foriphoneos
and one foriphonesimulator
. You can copysrc_py
into both of these folders, then rename thempygame
to make themimport
able from your game's code. You can then copy your built C modules from Meson into this folder so thepygame
module can see them on import (make sure they are namedbase.so
instead oflibbase.dylib
or whatever Meson calls them on build, they need to be.so
for the custom xcode build phases).Finally, you need to change
main.m
to 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.build
to support the "ios" plat.