Skip to content

file::load_file: extend the iOS chdir to tvOS as well - #1056

Merged
not-fl3 merged 1 commit into
not-fl3:masterfrom
benface:tvos-load-file-cwd
Jul 25, 2026
Merged

file::load_file: extend the iOS chdir to tvOS as well#1056
not-fl3 merged 1 commit into
not-fl3:masterfrom
benface:tvos-load-file-cwd

Conversation

@benface

@benface benface commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

load_file sets CWD to the app-bundle dir before hitting miniquad::fs::load_file, gated on #[cfg(target_os = "ios")]. tvOS apps have the exact same bundle layout and the exact same "CWD defaults to /" behavior, so tvOS builds silently miss every load_file call — and every set_pc_assets_folder(\"assets\") resolves to /assets/... (nonexistent).

The fix is one line: widen the predicate to any(target_os = \"ios\", target_os = \"tvos\"). iOS behavior is unchanged.

Verification

  • cargo build --target aarch64-apple-darwin — clean
  • cargo build --target aarch64-apple-ios — clean
  • cargo build --target aarch64-apple-tvos-sim — currently blocked at the miniquad level (upstream miniquad doesn't compile for tvOS yet — I sent a parallel PR there). With a local miniquad tvOS patch applied, I've verified that a real game (CHOMP, macroquad + miniquad + rodio) that previously fell back to macroquad's default pixel font on tvOS Simulator now correctly loads its bundled Sniglet TTF once this chdir kicks in.

Context

Sibling PRs going to raphamorim/objc-rs (Apple runtime selection) and not-fl3/miniquad (tvOS build support) for the same shape of Apple-family cfg oversight in each layer of the stack. Each PR stands on its own; the CHOMP tvOS build only becomes runnable end-to-end after all three land.

`load_file` sets CWD to the app-bundle dir before hitting
miniquad's file API, gated on `#[cfg(target_os = "ios")]`. tvOS
apps have the exact same bundle layout and the exact same
CWD-defaults-to-`/` behavior, so tvOS builds silently miss every
`load_file` call and each `set_pc_assets_folder("assets")`
resolves to `/assets/...`.

Widen the cfg to `any(target_os = "ios", target_os = "tvos")`.
One-line change; behavior on iOS unchanged.

Verified against host + `aarch64-apple-ios` locally. The
`aarch64-apple-tvos-sim` build isn't reachable in isolation until
`not-fl3/miniquad` picks up tvOS support (parallel PR sent), but
with a local miniquad patch bundled I've confirmed CHOMP's fonts
and other bundled assets now load correctly on tvOS Simulator.
benface added a commit to benface/miniquad that referenced this pull request Jul 25, 2026
`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
not-fl3 pushed a commit to not-fl3/miniquad that referenced this pull request Jul 25, 2026
`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-#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
@not-fl3

not-fl3 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Thanks for PR!

@not-fl3
not-fl3 merged commit 32b0fd0 into not-fl3:master Jul 25, 2026
6 checks passed
TheRedDeveloper pushed a commit to TheRedDeveloper/miniquad-fix that referenced this pull request Aug 12, 2026
`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
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