Skip to content

improve iOS and Android Support - #33

Merged
MasonRemaley merged 1 commit into
allyourcodebase:mainfrom
nat3Github:mobile
Sep 24, 2026
Merged

MasonRemaley merged 1 commit into
allyourcodebase:mainfrom
nat3Github:mobile

Conversation

@nat3Github

Copy link
Copy Markdown
Contributor

ci runs for iOS on macOS runners.
I tested this patch wired in as a backend in dvui on an old android phone (redmi note 10) and my iphone se 2nd gen.

we already have iOS support and Android support (in dvui) but it would be nice to improve android (compile sdl from source) and have it upstream @aycb for iOS for a canonical source

- iOS (src/ios.zig) and Android (src/android.zig) default target configs.
- New -Dinclude_path/-Dframework_path/-Dlibrary_path options for SDKs not
  bundled with Zig (iOS SDK, Android NDK). Unlike --sysroot they only
  affect the SDL library, not host steps in the build graph.
- sdl.zon: split the sources macOS and iOS share into an `apple` group,
  add a `uikit` group, and add the dummy tray to the android group.
- Android: don't list sources that the generic group already compiles
  (they were built twice), build with pic, compile hidapi/android/hid.cpp
  for the JNI stubs SDL_android.c registers.
- CI: build for iOS on macOS runners.

Tested on a physical iPhone and a physical Android device.
nat3Github added a commit to nat3Github/zig-lib-dvui-dev-fork that referenced this pull request Sep 24, 2026
Switches the sdl3 dependency from nat3Github/lib-sdl3-dev-fork to
nat3Github/lib-aycb-sdl-dev (mobile), which is allyourcodebase/SDL plus
iOS/Android default target configs (allyourcodebase/SDL#33, pending).
Switch the pin to allyourcodebase/SDL once that merges.

- linkSdl3: forwards include_path/framework_path/library_path (NDK
  headers for Android). Drops the cross-MSVC GAMEINPUT override
  (aycb already sets HAVE_GAMEINPUT_H=0) and iOS sanitize_c=off (the
  iOS example bundles ubsan_rt instead, like Android).
- installAndroidSdl3(): installs libSDL3.a + SDL's Java sources, so
  native and Java SDL come from the same source. Android translate-c
  gets NDK headers and aro workarounds; pic for Android.
- installIosStaticLib(): re-archive with 8-byte-aligned darwin members
  for Xcode's ld.
- android example: no prebuilt .aar; Gradle compiles SDL's Java from
  zig-out, CMake links libsdl_hello.a + whole-archive libSDL3.a.
  Gradle 9.7.1 / AGP 9.4.0, minSdk 24.

Tested on a physical Android device and iPhone.
nat3Github added a commit to nat3Github/zig-lib-dvui-dev-fork that referenced this pull request Sep 24, 2026
Switches the sdl3 dependency from nat3Github/lib-sdl3-dev-fork to
nat3Github/lib-aycb-sdl-dev (mobile), which is allyourcodebase/SDL plus
iOS/Android default target configs (allyourcodebase/SDL#33, pending).
Switch the pin to allyourcodebase/SDL once that merges.

- linkSdl3: forwards include_path/framework_path/library_path (NDK
  headers for Android). Drops the cross-MSVC GAMEINPUT override
  (aycb already sets HAVE_GAMEINPUT_H=0) and iOS sanitize_c=off (the
  iOS example bundles ubsan_rt instead, like Android).
- installAndroidSdl3(): installs libSDL3.a + SDL's Java sources, so
  native and Java SDL come from the same source. Android translate-c
  gets NDK headers and aro workarounds; pic for Android.
- installIosStaticLib(): re-archive with 8-byte-aligned darwin members
  for Xcode's ld.
- android example: no prebuilt .aar; Gradle compiles SDL's Java from
  zig-out, CMake links libsdl_hello.a + whole-archive libSDL3.a.
  Gradle 9.7.1 / AGP 9.4.0, minSdk 24.

Tested on a physical Android device and iPhone.
@MasonRemaley

Copy link
Copy Markdown
Contributor

Awesome, thanks for the PR! :)

@MasonRemaley
MasonRemaley merged commit 5d683b9 into allyourcodebase:main Sep 24, 2026
3 of 6 checks passed
@nat3Github

Copy link
Copy Markdown
Contributor Author

thank you! and somewhat related do you know more about this question i posted on ziggit: https://ziggit.dev/t/canonical-cross-compiling-w-system-dependencies-pkg-config-sysroot-and-search-prefix/17568 ?
i am still looking for an answer but found none so far.

nat3Github added a commit to nat3Github/zig-lib-dvui-dev-fork that referenced this pull request Sep 25, 2026
Switches the sdl3 dependency from nat3Github/lib-sdl3-dev-fork to
nat3Github/lib-aycb-sdl-dev (mobile), which is allyourcodebase/SDL plus
iOS/Android default target configs (allyourcodebase/SDL#33).

- linkSdl3: forwards include_path/framework_path/library_path (NDK
  headers for Android). Drops the cross-MSVC GAMEINPUT override
  (aycb already sets HAVE_GAMEINPUT_H=0) and iOS sanitize_c=off (the
  iOS example bundles ubsan_rt instead, like Android).
- installAndroidSdl3(): installs libSDL3.a + SDL's Java sources, so
  native and Java SDL come from the same source. Android translate-c
  gets NDK headers and aro workarounds; pic for Android.
- installIosStaticLib(): re-archive with 8-byte-aligned darwin members
  for Xcode's ld.
- android example: no prebuilt .aar; Gradle compiles SDL's Java from
  zig-out, CMake links libsdl_hello.a + whole-archive libSDL3.a.
  Gradle 9.7.1 / AGP 9.4.0, minSdk 24 (since lower then this we need workarounds for some of zig std).

Tested on a physical Android device and iPhone.
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