Skip to content

SDL callbacks and iOS simulator support - #51

Open
cwindolf wants to merge 6 commits into
allyourcodebase:mainfrom
cwindolf:cw-dev
Open

cwindolf wants to merge 6 commits into
allyourcodebase:mainfrom
cwindolf:cw-dev

Conversation

@cwindolf

@cwindolf cwindolf commented Oct 25, 2026 •

Copy link
Copy Markdown

Hi all,

This PR does a couple of things to get SDL working on iOS with SDL's callbacks.

  • Passes Apple SDK paths to translate-c
  • Disables the sanitizer on iOS, where it crashes at runtime (not build time)
  • Adds a new -Dmain_callbacks: when passed, src/sdl_main.c includes SDL's SDL_main.h
  • Also adds this build helper addAppleSdkPathsToModule which users can call in their builds to link UIKit etc as needed. I'm not sure if this part would be controversial and happy to remove it. It's used in my demo (below) so I could move it there, but I think that any iOS-targeting user would need something similar.

I haven't updated the demo in this repo since I didn't want to force it to use callbacks, but I reworked it here:
https://github.com/cwindolf/zig-sdl3-callbacks-example. In that repository, you can zig build ios-run -Dtarget=aarch64-ios-simulator and see the rainbow appear on the iPhone of your choice.

I wrote this in a vacuum so I apologize if it conflicts with other PRs or handles existing issues in a non-optimal way. I tried to get a handle on those questions, here are some notes:

Thank you for taking a look at this. Let me know if it's useful, and if so if there are any changes you'd suggest! For now, I haven't touched the README or the example. I wanted to check in about the approach first, but I could at least mention -Dmain_callbacks in the README if that's of interest. Not sure what to do about the example, I'm open to any options.

… and other apple

related stuff)

retains my stuff: SDL3_main/-Dmain_callbacks; helpers for finding and linking Apple
SDK's for iOS; and this thing where sanitize_c is not working on iOS (seems that Zig's
UBSan does not understand something Apple-related)
…un always, and also

unify SDK logic in one place
@MasonRemaley

Copy link
Copy Markdown
Contributor

Nice thanks for the PR! I'm going to have access to a mac to test with next week, at which point I'll review all the Apple related PRs. No worries about conflicts with other open PRs I can sort all that out. :)

@cwindolf

Copy link
Copy Markdown
Author

Great, thank you! Happy to break this into pieces or remove things, whatever seems best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants