Skip to content

Comments

fix: iOS Kotlin/Native + Now Playing + WebRTC embed fixes #100

Open
hayupadhyaya wants to merge 2 commits intomusic-assistant:mainfrom
hayupadhyaya:fix/ios-build
Open

fix: iOS Kotlin/Native + Now Playing + WebRTC embed fixes #100
hayupadhyaya wants to merge 2 commits intomusic-assistant:mainfrom
hayupadhyaya:fix/ios-build

Conversation

@hayupadhyaya
Copy link
Contributor

@hayupadhyaya hayupadhyaya commented Feb 20, 2026

Fixes three issues that prevent the iOS app from building and running correctly.

AudioStreamManager.ktsynchronized() removed
synchronized(lock) {} is JVM-only and not available in Kotlin/Native. Replaced with Mutex.withLock {} on suspend functions and runBlocking { mutex.withLock {} } on the non-suspend close().

MainDataSource.kt — Now Playing never populated
updateNowPlaying() was fully implemented in Swift (NowPlayingManager) and wired through PlatformAudioPlayer to Kotlin, but was never called. Added a collector on localPlayer that pushes
track title, artist, album, artwork URL, duration, elapsed time and playback rate to the iOS Now Playing center on every player state update (~500 ms cadence).

project.pbxprojWebRTC.framework not embedded
The build phase script copied WebRTC.framework to the linker search path but never placed it inside the .app bundle. At launch, dyld looked for it at
@executable_path/Frameworks/WebRTC.framework, didn't find it, and aborted. Fixed by embedding the correct slice into the bundle and signing with $EXPANDED_CODE_SIGN_IDENTITY (developer cert
for device builds, ad-hoc for simulator).

- Replace synchronized() with Mutex.withLock{} in AudioStreamManager.kt
  (synchronized is JVM-only; suspend functions use withLock, close() uses runBlocking)
- Wire updateNowPlaying() in MainDataSource to push track metadata, artwork,
  elapsed time and playback rate to the iOS Now Playing center on every
  local player state change (~500 ms cadence via position tracker loop)
- Embed WebRTC.framework into the app bundle in the Xcode build phase script
  and sign it with $EXPANDED_CODE_SIGN_IDENTITY so dyld can find it at
  runtime (without this the app crashes immediately on launch)
@hayupadhyaya hayupadhyaya changed the title fix: iOS build and runtime fixes for Kotlin/Native + Now Playing fix: iOS Kotlin/Native + Now Playing + WebRTC embed fixes Feb 20, 2026
- Fix no-audio bug: MessageDispatcher and AudioStreamManager each had
  independent TimeSource.Monotonic.markNow() epochs; ClockSynchronizer
  now owns the shared startMark and exposes getCurrentTimeMicros() so
  serverLoopOriginLocal and currentLocalTime are always in the same domain
- Add AVAudioSession interruption + route-change handlers to
  NativeAudioController; auto-resumes playback after phone calls/Siri
- Add writeRawPcmNSData(NSData) for efficient Kotlin→Swift PCM transfer
  via usePinned bulk copy (avoids per-byte Swift interop loop)
- Fix DataChannelWrapper binary fast path: first-byte check instead of
  full decodeToString() on every audio chunk at 50-100/sec
- Fix OAuthHandler: open OAuth URLs in Safari instead of throwing
  UnsupportedOperationException
- Fix SystemAppearance: apply overrideUserInterfaceStyle to all windows
- Fix Config.xcconfig: rename BUNDLE_ID to PRODUCT_BUNDLE_IDENTIFIER
- Fix project.pbxproj: copy compose-resources into app bundle so
  Compose Multiplatform assets (images, fonts) resolve at runtime
- Update README: iOS features section + building from source
- Update .claude docs: mark iOS volume, background playback, and
  no-audio bug as resolved (pending end-to-end tests)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please merge main into your branch? ServiceClient got changed a bit. I apologize for inconvenience!

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