Skip to content

feat(examples): Apple TV target for the SwiftUI demo - #109

Open
shaaaaawn wants to merge 1 commit into
google:mainfrom
shaaaaawn:feat/tvos-demo
Open

shaaaaawn wants to merge 1 commit into
google:mainfrom
shaaaaawn:feat/tvos-demo

Conversation

@shaaaaawn

Copy link
Copy Markdown
Contributor

Summary

The SwiftUI demo in mobile/examples/ios_swiftui is the package's only runnable host, and it is iOS-only. Building on the tvOS RealityKit layer (#108), this PR adds an Apple TV target that compiles the demo's preset scenes on device and explores them with the Siri Remote. Apple TV has no touchscreen, so the camera and selection come from the remote.

Trailer (Apple TV 4K simulator, tvOS 27.0; 46 s, silent):

three-live-apple-tv-trailer.mp4

Controls

Siri Remote Action
Swipe on the touch surface Orbit the camera
Clickpad ring / arrows Step the camera 15°
Select Run onSelect on the node under a center reticle
Play/Pause Reset the camera
Menu Back to the scene list; from there, leave the app

Design

  • TVContentView.swift drives the camera with XROrbitCameraState, as the iOS demo does, and Select calls XRLiveRealityKitSession.handleTap(at:in:) at the reticle, so onSelect behaviors run as they do on iOS. Auto-rotate pauses while exploring, so the model holds still under the reticle.
  • Remote buttons are tap recognizers on the focused ARView, so Menu is consumed only while exploring and the app never traps the user. Leaving Explore puts focus back on the Explore button.
  • The iOS and tvOS targets share one XcodeGen target template. The iOS app is unchanged: the shared Swift files add || os(tvOS) to their platform gates, and the app entry point shows TVContentView on tvOS.
  • No library, trait, schema, compiler or C ABI change: the diff is limited to mobile/examples/ios_swiftui and .gitignore.
  • The TV app keeps the default ThreeLiveCapabilities policy (scripts only): its bundled scenes need no network, storage, sensor or AI capability.

Docs

The demo README gains a short Apple TV section (requirements, controls, simulator keys, UI test command) and its intro lists the Apple TV target; .gitignore gains the generated InfoTV.plist.

Testing

9504393 plus this commit, Xcode 27.2, Swift 6.4.2. The walkthrough, device builds and images come from an earlier revision on 6b619b4 plus the tvOS RealityKit commit, with the same app code (#107, merged in between, touched no Swift):

  • Fresh clone, following the demo README as written: step 1's default build_ios_xcframework.sh (no flags) built both XCFrameworks with tvOS slices, then xcodegen generate, the ThreeLiveDemoTV scheme built for an Apple TV simulator (and ThreeLiveDemo for iOS), and the Apple TV section's xcodebuild test command passed (3/3, before the fourth test below was added). One snag predates this PR: step 1's npm ci fails on a fresh clone because the repo has no package-lock.json; npm install, as CI runs it, works and leaves the committed engine asset unchanged.
  • Both demos build for device with no new warnings. The iOS target's effective build settings match main's, and CI's ThreeLiveDemo scheme is still created in a fresh checkout.
  • xcodebuild test -scheme ThreeLiveDemoTV on tvOS 26.5 and tvOS 27.0 simulators: 4/4 pass on each. ThreeLiveDemoTVUITests drives the app with the simulated Siri Remote (XCUIRemote):
    • Explore → Select (miss) → Menu returns focus to Explore without leaving the app.
    • Explore holds the model still: two screenshots 2 s apart differ in under 1% of pixels (4–5% with the auto-rotate pause removed).
    • Instanced Lattice → Select hits LatticeEnergyCore.
    • Menu on the scene list leaves the app.
  • By hand on an Apple TV 4K simulator (tvOS 27.0): the arrows step the camera 15°, Select picks LatticeEnergyCore, Play/Pause resets the camera, Menu returns focus to Explore, and Menu on the scene list leaves the app.

Apple TV 4K simulator, tvOS 27.0:

Scene list: CAD Gears compiled on device in 330 ms Explore: Select hits LatticeEnergyCore Orbited with the remote
Scene list with CAD Gears selected and its compile time Explore mode: HUD reads Selected LatticeEnergyCore, reticle on the knot Instanced Lattice after orbiting the camera with the remote

All 10 bundled presets in Explore after Play/Pause (camera reset), each compiled on device; the HUD shows its compile-and-load time:

Ten Apple TV screenshots in a 5 by 2 grid: Espresso, Living Room, CAD Gears, Holo TSL, Instanced Lattice, Pagoda, Ballpit, Workbench, Gemini AI and Robotic Arm IK, each in Explore with its compile time in the HUD

Not covered

  • Swipe feel on a physical Siri Remote: XCUIRemote can't swipe.
  • CI is unchanged and builds only the iOS demo (-scheme ThreeLiveDemo), so it doesn't compile the TV target. Happy to add a generic/platform=tvOS build of ThreeLiveDemoTV to the Swift job if you'd like it covered.
  • The UI tests need a tvOS simulator, so they run locally with the README command.
  • The demo runs only its bundled preset scripts: no network input, accounts or persistence.

Add ThreeLiveDemoTV (tvOS 26+), which compiles the demo's preset scenes
on device and explores them with the Siri Remote: swipe on the touch
surface to orbit, click the clickpad ring or arrows to step 15 degrees,
Select runs onSelect on the node under a center reticle, Play/Pause
resets the camera, and Menu returns to the scene list (and, from there,
leaves the app as tvOS expects).

The camera reuses the iOS demo's XROrbitCameraState, and Select calls
XRLiveRealityKitSession.handleTap(at:in:) at the reticle, so onSelect
behaviors run as they do on iOS. Auto-rotate pauses while exploring, so
the model holds still under the reticle. Remote buttons are tap
recognizers on the focused ARView, so Menu is consumed only while
exploring, and leaving Explore puts focus back on the Explore button.
The iOS and tvOS apps share one XcodeGen target template, and the iOS
app's behavior is unchanged. The demo README gains an Apple TV section
(requirements, controls and the UI test command).

ThreeLiveDemoTVUITests drives the app with XCUIRemote: Explore, Select
(miss) and Menu return focus to Explore without leaving the app; Explore
holds the model still; Select on Instanced Lattice hits
LatticeEnergyCore; Menu on the scene list leaves the app. CI is
unchanged. Swiping on a physical Siri Remote is not covered (XCUIRemote
cannot swipe).

This branch has not been deployed

No deployments
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.

1 participant