Skip to content

feat(app): CarPlay station list, behind SUBWAVE_CARPLAY=1 - #15

Merged
perminder-klair merged 2 commits into
mainfrom
feat/carplay
Nov 27, 2026
Merged

perminder-klair merged 2 commits into
mainfrom
feat/carplay

Conversation

@perminder-klair

@perminder-klair perminder-klair commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Ported from perminder-klair/subwave#2134. On main (967d0bd), after the Siri/Shortcuts PR (#14) whose bridge it uses and the Android Auto PR (#16).

Summary

SUB/WAVE in the car's app grid: the saved stations as a list, a tap tunes in, then the system Now Playing screen with a heart. Swift draws, JS decides: a tap goes through the same bridge as "Hey Siri, tune in", so switching and tuning in stay in src/intents/tune.ts, which hands the load to the mounted player and fits every wait to the deadline the bridge sends.

tap a station in CarPlay
  CarPlaySceneDelegate.tuneIn(station)              # _shared/SubwaveCarPlay.swift
    SubwaveIntentBridge.perform(.tuneIn, station)   # same path as Siri, with its deadline
      src/intents/tune.ts → tune-flow.ts → the mounted player (or a direct load with none)
    push CPNowPlayingTemplate                       # heart → bridge .like; a failure shows its message

the car launches the app (no phone screen)
  CarPlaySceneDelegate.didConnect
    ReactBoot.startIfNeeded()                       # RN into a window with no scene; clears a stale on-air flag
  …later, the phone opens the app
  SubwavePhoneSceneDelegate.willConnectTo
    moves that window onto the phone's scene        # sized to it; one React tree, not two
    re-sends the launch's URLs, activities and quick action through Expo's own handlers

Off unless SUBWAVE_CARPLAY=1 at prebuild. A device build can't be signed with com.apple.developer.carplay-audio until Apple grants it on the App ID. A signed Release device build with the flag on fails today (Entitlement com.apple.developer.carplay-audio not found and could not be included in profile). The entitlement request was submitted to Apple on 2026-11-27, and the flag stays off in eas.json until it's approved and enabled on the App ID. plugins/withCarPlay.js changes the plist only when that variable is set, following Apple's CarPlay manifest:

 UIApplicationSceneManifest
-  UIApplicationSupportsMultipleScenes false
+  UIApplicationSupportsMultipleScenes true   # a phone scene and a CarPlay one
   UIWindowSceneSessionRoleApplication
-    EXExpoAppSceneDelegate
+    SubwavePhoneSceneDelegate          # subclass of Expo's; adopts a running RN window, refuses a second one
+  CPTemplateApplicationSceneSessionRoleApplication
+    CPTemplateApplicationScene / SubwaveCarPlaySceneDelegate
 entitlements
+  com.apple.developer.carplay-audio

With multiple scenes on, iPadOS can open a second window of the app. One React tree plays one stream, so SubwavePhoneSceneDelegate asks for that session's destruction instead of starting a second player.

The on-air flag has one reader, OnAirFlag (_shared/OnAirFlag.swift), shared by the CarPlay list and the tune control. The app-intents module posts SubwaveStationsChanged from setStations and SubwaveOnAirChanged from setOnAir; both names are matched by string, with notes on each side.

Evidence

  • Flag off: a flag-off npx expo prebuild -p ios --clean gives Expo's own scene manifest and no CarPlay entitlement, and scripts/carplay-plugin.test.ts runs the plugin and expo-build-properties in app.json's order and checks the Info.plist and entitlements are the same as without the plugin. It also checks the flag-on manifest, that app.json lists the plugin first, and that the plugin leaves expo-build-properties' own manifest object alone (it used to edit it in place).
  • Flag on: SUBWAVE_CARPLAY=1 npx expo prebuild -p ios --clean writes the manifest and entitlement above. An Xcode 27 Release build for the simulator succeeds, and a normal launch on the iPhone 18 Pro simulator fills the screen in one window.
  • npm run lint clean (one existing warning in onboarding.tsx); npm test 593 pass, 5 skipped.
  • Not run yet: the CarPlay screens, the car-first launch and an iPad second window. Xcode 27 has no Simulator.app, and DeviceHub offers no CarPlay display for simulators (FB24785359). The checklist and the routes that do work (Xcode 26's Simulator, DeviceHub's CarPlay Simulator with a USB iPhone once the entitlement is granted) are in docs/TESTING.md. That's why this is a draft.

Merge Danger

Door: two-way

Blast Radius: none for store builds while the flag is off

The Swift compiles into every build, but nothing names its classes unless the plugin is on. What does run with the flag off:

  • setStations posts SubwaveStationsChanged and setOnAir posts SubwaveOnAirChanged, in-process notifications that nothing observes.
  • The tune control reads the on-air flag through OnAirFlag: same suite, same key.
  • SubwaveIntentBridge drops its iOS 17 availability attribute; it uses nothing newer than the 16.4 deployment target.

All native, so it ships in a binary, not over the air.

…, Apple's scene manifest

- PhoneSceneDelegate sizes the window ReactBoot made to its scene, re-sends
  a connection's URLs, activities and quick action through Expo's own
  handlers (open options, RCTLinkingManager fallback and dedupe), and
  refuses a second window.
- With the flag on, the manifest follows Apple's CarPlay one:
  UIApplicationSupportsMultipleScenes true and UISceneClassName
  CPTemplateApplicationScene. On iPad that allows a second window, which
  one React tree can't serve, so the phone delegate destroys it.
- OnAirFlag (_shared) is the one reader of the on-air flag, for CarPlay and
  the tune control, with matched-by-string notes on both sides. ReactBoot
  clears a flag a killed app left set.
- setStations posts SubwaveStationsChanged; StationIndex.reindex no longer
  doubles as CarPlay's signal.
- A failed like from the CarPlay heart shows the bridge's message.
- withCarPlay copies expo-build-properties' manifest instead of editing its
  module-level object, renames enabled() to carPlayEnabled(), and
  scripts/carplay-plugin.test.ts checks the plist with the flag unset and set.
- TESTING.md: the SDK 58 check for the delegate override, and the checklist.
@perminder-klair
perminder-klair marked this pull request as ready for review November 27, 2026 18:44
@perminder-klair
perminder-klair merged commit daf0f30 into main Nov 27, 2026
2 checks passed
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