Skip to content

Add support for CarPlay#111

Closed
docmeth02 wants to merge 25 commits intokepelet:developfrom
docmeth02:feat/carplay
Closed

Add support for CarPlay#111
docmeth02 wants to merge 25 commits intokepelet:developfrom
docmeth02:feat/carplay

Conversation

@docmeth02
Copy link
Copy Markdown
Contributor

This is a bit of a WIP since i can only test this in the iphone simulator without having the proper entitlements added from apple. It fully works, but does change some points in how the app works on all platforms.

Major changes i made:

  1. PlayerViewModel → Singleton (PlayerViewModel.swift)
  • Added static let shared = PlayerViewModel() — the phone UI and CarPlay now share one player instance
  • ContentView uses PlayerViewModel.shared instead of creating its own
  1. Audio Session Lifecycle (App.swift + PlayerViewModel.swift)
  • Removed setActive(true) from app launch — this was killing car FM radio the moment flo connected to CarPlay
  • Added setActive(true) in setNowPlaying() — activates only when actually starting playback
  • Added setActive(false, options: .notifyOthersOnDeactivation) in destroyPlayerAndQueue() — releases audio focus so other audio sources can resume
  1. Now Playing / Playback Indicator Fixes (PlayerViewModel.swift)
  • initNowPlayingInfo now merges with the existing nowPlayingInfo dict instead of creating a fresh one (was wiping playback rate/elapsed time)
  • seek(to:) now updates self.progress so subsequent calls use the correct position
  • play() sets playbackState = .playing, pause() sets .paused — CarPlay now knows the actual state instead of guessing from playback rate
  1. Locked-Phone Security (KeychainManager.swift + LocalFileManager.swift)
  • Keychain: .afterFirstUnlockThisDeviceOnly — auth tokens accessible when phone is locked in the car
  • Downloaded files: .completeUntilFirstUserAuthentication — offline music plays when phone is locked
  1. Config (Info.plist + flo.entitlements + project.pbxproj)
  • Scene manifest with CarPlay scene configuration
  • com.apple.developer.carplay-audio entitlement
  • Auto scene manifest generation disabled, CarPlay files + framework added to target

Impact on non-CarPlay usage: The audio session and now playing are improvements for the phone app too — lock screen controls and AirPlay will be more
reliable.

So to actually test this in testflight, you would need to first apply for the carplay entitlement with the account that builds the testflight binaries (https://developer.apple.com/documentation/carplay/requesting-carplay-entitlements)

Simulator Screenshot - iPhone 17 - 2026-02-22 at 13 21 13 Simulator Screenshot - iPhone 17 - 2026-02-22 at 13 20 58 Simulator Screenshot - iPhone 17 - 2026-02-22 at 13 20 43 Simulator Screenshot - iPhone 17 - 2026-02-22 at 13 20 13

faultables and others added 13 commits February 17, 2026 23:52
This commit addresses multiple issues causing crashes on smaller screens,
particularly iPhone 13 mini (390pt width):

1. Fixed ContentView floating player padding scope issue
   - Variable was declared in wrong scope causing undefined behavior
   - Combined padding values into single expression
   - Updated threshold from 375pt to 390pt to include iPhone 13 mini

2. Restored text scaling in StatCardView
   - Added .minimumScaleFactor(0.7) to all text elements
   - Prevents text overflow crashes when content is too long
   - Applied to title, value, and subtitle text in both iOS 26+ and legacy versions

3. Conditional layout in HomeView to prevent geometry loops
   - Small screens (≤390pt): Use regular HStack without EqualHeightItem
   - Larger screens (>390pt): Use EqualHeightHStack for visual consistency
   - Avoids infinite geometry calculation loop when combining
     minimumScaleFactor with EqualHeightItem

Related to PR kepelet#102 and PR kepelet#105
Fixes white screen crashes reported on iPhone 13 mini (builds 206-207)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Removed duplicate bottom padding from FloatingPlayerView that was causing excessive spacing below the miniplayer. ContentView already applies appropriate bottom padding to account for the tab bar.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Handle missing `song` key in getSimilarSongs2 response without crashing
- Show alert to user on empty results or network failure
- Replace duplicate ArtistRadioPlayable with existing RadioEntity
- Increase default song count to 100

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Align Artist Radio button to leading edge
- Rename button label to "Play Artist Radio"
- Reduce miniplayer bottom padding to close gap above tab bar

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@faultables
Copy link
Copy Markdown
Member

woah, looks nice, thanks! will add it to 2.2!

@docmeth02
Copy link
Copy Markdown
Contributor Author

rebased onto version 2.1 codebase and added the new artist radio and top songs buttons to carplay

image

faultables pushed a commit that referenced this pull request Mar 3, 2026
The cherry-pick of PR #111 (CarPlay support) replaced the project.pbxproj
with the fork's version, dropping the flo Watch Watch App build target.

Restore the Watch target by starting from the pre-cherry-pick pbxproj
and surgically adding only CarPlay-specific entries:
- CarPlay.framework linkage
- CarPlayCoordinator, CarPlaySceneDelegate, CarPlayNowPlayingManager,
  CarPlayImageLoader file references and source build phase entries
- CarPlay and Frameworks PBXGroups
- flo.entitlements reference and CODE_SIGN_ENTITLEMENTS build setting

https://claude.ai/code/session_015rkZGZikDmQB6kje6uGB6n
@faultables
Copy link
Copy Markdown
Member

ok i think we can ship this (all commits in this PRs are already on release 2.2 btw)

image

@faultables
Copy link
Copy Markdown
Member

@docmeth02 does the CarPlay support still work on this branch? #118

@docmeth02
Copy link
Copy Markdown
Contributor Author

yup, it is working in the ios simulator @faultables

@faultables
Copy link
Copy Markdown
Member

yup, it is working in the ios simulator @faultables

how do i check it on my xcode project? somehow on my carplay simulator can’t see any flo apps

@docmeth02
Copy link
Copy Markdown
Contributor Author

oh yeah i noticed you are missing the carplay entitlement in #118

`diff --git a/flo.xcodeproj/project.pbxproj b/flo.xcodeproj/project.pbxproj
index 0188792..cdb74e3 100644
--- a/flo.xcodeproj/project.pbxproj
+++ b/flo.xcodeproj/project.pbxproj
@@ -970,6 +970,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
+ CODE_SIGN_ENTITLEMENTS = flo/flo.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 211;
@@ -1013,6 +1014,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
+ CODE_SIGN_ENTITLEMENTS = flo/flo.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 211;

`
shows up for me again in the Simulator after that patch 👍

@faultables
Copy link
Copy Markdown
Member

closing this as all commits have been cherrypicked to release/2.2

@faultables faultables closed this Mar 16, 2026
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.

3 participants