Skip to content

Add tvOS build support (reuse iOS event loop, widen Apple cfg guards)#651

Merged
not-fl3 merged 1 commit into
not-fl3:masterfrom
benface:tvos-build-support
Jul 25, 2026
Merged

Add tvOS build support (reuse iOS event loop, widen Apple cfg guards)#651
not-fl3 merged 1 commit into
not-fl3:masterfrom
benface:tvos-build-support

Conversation

@benface

@benface benface commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

aarch64-apple-tvos and aarch64-apple-tvos-sim are stable Rust tier-3 targets installable via plain rustup target add — no -Z build-std needed. But miniquad currently misses tvOS from every target_os = \"ios\" cfg guard, so a tvOS build fails to compile.

This PR widens the Apple-family gates so tvOS reuses the iOS event loop (native::ios::run), UIKit link, Objective-C runtime, and Metal storage-mode selection. No new tvOS-specific code is added — the same iOS surface is compiled and dispatched for tvOS.

Files

  • Cargo.toml — pull objc-rs on tvOS as well.
  • src/lib.rsstart() dispatch and apple_view_ctrl(). Without the dispatch widen, start() returns immediately on tvOS (the enclosing app exits voluntarily right after launch).
  • src/native.rspub mod apple, pub mod ios, and the NativeDisplayData::view_ctrl field + its initializer.
  • src/native/apple/frameworks.rs — UIKit link (GLKit stays iOS-only since tvOS has no OpenGL ES).
  • src/graphics/metal.rsUNIFORM_BUFFER_ALIGN selection and the two MTLResourceOptions::CPUCacheModeWriteCombined branches.

Verification

cargo build against all five Apple targets:

  • aarch64-apple-darwin — clean
  • aarch64-apple-ios — clean
  • aarch64-apple-ios-sim — clean
  • aarch64-apple-tvosnow builds
  • aarch64-apple-tvos-simnow builds

A downstream game (CHOMP, macroquad + miniquad + rodio) using this branch renders correctly on the tvOS Simulator — Metal draw calls, MetalKit view attachment, audio, and asset loading all work. The Rust runtime is complete.

Not in scope (deliberate)

  • Input. miniquad's iOS event loop reacts to UITouch on the MTKView. On tvOS, touch events only arrive from the Siri Remote's touch surface; menu / D-pad navigation goes through UIPress + the focus engine and is not wired here. An app built with this patch will render but won't accept remote-native input yet.
  • App-level scaffolding. Info.plist scene manifest, main.m bridging, asset catalogs, LaunchScreen setup — all app-owned and out of scope for miniquad itself.
  • Metal alignment on Apple Silicon tvOS sim. Existing iOS cfg (target_arch = \"x86_64\" picks the 256-byte alignment) is preserved verbatim for tvOS. Same known-imperfect gate, no attempt to fix here.

Related

Two other Apple-family cfg oversights in the stack, each getting the same shape of fix:

  • raphamorim/objc-rs#3 — Apple runtime cfg widen (blocks tvOS link with Undefined symbol: _objc_msg_lookup until it lands)
  • not-fl3/macroquad#1056load_file CWD chdir for tvOS (silently missing bundled assets otherwise)

Each PR stands on its own; the CHOMP tvOS build only becomes runnable end-to-end after all three land.

`aarch64-apple-tvos` and `aarch64-apple-tvos-sim` are stable Rust
tier-3 targets installable via plain `rustup target add`, but
miniquad currently misses tvOS from every `target_os = "ios"` cfg
gate, so a tvOS build fails to compile.

This commit widens the Apple-family gates so tvOS reuses the iOS
event loop (`native::ios::run`), UIKit link, Objective-C runtime,
and Metal storage-mode selection. No new tvOS-specific code is
added — the same iOS surface is compiled and dispatched for tvOS.

Files touched:

- `Cargo.toml` — pull `objc-rs` on tvOS as well.
- `src/lib.rs` — `start()` dispatch and `apple_view_ctrl()`.
  Without the dispatch widen, `start()` returns immediately on
  tvOS (the enclosing app exits voluntarily on launch).
- `src/native.rs` — `pub mod apple`, `pub mod ios`, and the
  `NativeDisplayData::view_ctrl` field + its initializer.
- `src/native/apple/frameworks.rs` — UIKit link (GLKit stays
  iOS-only since tvOS has no OpenGL ES).
- `src/graphics/metal.rs` — `UNIFORM_BUFFER_ALIGN` selection
  and the three `MTLResourceOptions` branches (matched to the
  post-not-fl3#640 shape now on master).

Verified with `cargo build` against all five Apple targets:

- `aarch64-apple-darwin` — clean
- `aarch64-apple-ios` — clean
- `aarch64-apple-ios-sim` — clean
- `aarch64-apple-tvos` — now builds
- `aarch64-apple-tvos-sim` — now builds

Not in scope (deliberate):

- **Input.** miniquad's iOS event loop reacts to `UITouch` on the
  `MTKView`. On tvOS, touch events only arrive from the Siri
  Remote's touch surface; menu / D-pad navigation goes through
  `UIPress` + the focus engine and is not wired here. An app
  built with this patch will render but won't accept
  remote-native input yet.
- **App-level scaffolding.** Info.plist scene manifest,
  `main.m` bridging, asset catalogs, LaunchScreen setup — all
  app-owned and out of scope for miniquad itself.

Sibling PRs of the same shape:
- raphamorim/objc-rs#3 — Apple runtime cfg widen (merged)
- not-fl3/macroquad#1056 — `load_file` CWD chdir for tvOS
@benface
benface force-pushed the tvos-build-support branch from 8afcf99 to 616ead9 Compare July 25, 2026 16:17
@not-fl3
not-fl3 merged commit b843cdd into not-fl3:master Jul 25, 2026
11 checks passed
@not-fl3

not-fl3 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Thanks for PR!

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