Add tvOS build support (reuse iOS event loop, widen Apple cfg guards)#651
Merged
Conversation
`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
force-pushed
the
tvos-build-support
branch
from
July 25, 2026 16:17
8afcf99 to
616ead9
Compare
Owner
|
Thanks for PR! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
aarch64-apple-tvosandaarch64-apple-tvos-simare stable Rust tier-3 targets installable via plainrustup target add— no-Z build-stdneeded. But miniquad currently misses tvOS from everytarget_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— pullobjc-rson tvOS as well.src/lib.rs—start()dispatch andapple_view_ctrl(). Without the dispatch widen,start()returns immediately on tvOS (the enclosing app exits voluntarily right after launch).src/native.rs—pub mod apple,pub mod ios, and theNativeDisplayData::view_ctrlfield + 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_ALIGNselection and the twoMTLResourceOptions::CPUCacheModeWriteCombinedbranches.Verification
cargo buildagainst all five Apple targets:aarch64-apple-darwin— cleanaarch64-apple-ios— cleanaarch64-apple-ios-sim— cleanaarch64-apple-tvos— now buildsaarch64-apple-tvos-sim— now buildsA 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)
UITouchon theMTKView. On tvOS, touch events only arrive from the Siri Remote's touch surface; menu / D-pad navigation goes throughUIPress+ the focus engine and is not wired here. An app built with this patch will render but won't accept remote-native input yet.main.mbridging, asset catalogs, LaunchScreen setup — all app-owned and out of scope for miniquad itself.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:
Undefined symbol: _objc_msg_lookupuntil it lands)load_fileCWD 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.