From 1cbaf22d3c5eb9e804d62fd38aecf1871a9b28c6 Mon Sep 17 00:00:00 2001 From: Dylan Audius Date: Thu, 8 Oct 2026 01:40:56 -0700 Subject: [PATCH] fix(mobile): patch SwiftAudioEx insert index for one-item queues Co-Authored-By: Claude Opus 5.5 --- packages/mobile/ios/Podfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/mobile/ios/Podfile b/packages/mobile/ios/Podfile index c5d685c23e7..fa8f6f35214 100644 --- a/packages/mobile/ios/Podfile +++ b/packages/mobile/ios/Podfile @@ -140,6 +140,24 @@ target 'AudiusReactNative' do end end + # SwiftAudioEx 1.x only shifts the current index for an insert in front + # of the current item when the queue already has more than one item. With + # a single item, inserting at 0 leaves the index one slot early, so the + # player replays the current track instead of advancing. Fixed upstream + # on main but not released. Fail if the line changes so an update can't + # silently drop the patch. + queue_manager = File.join(__dir__, 'Pods/SwiftAudioEx/Sources/SwiftAudioEx/QueueManager.swift') + buggy_line = 'if (self.items.count > 1 && currentIndex >= index) {' + fixed_line = 'if (self.items.count > 0 && currentIndex >= index) {' + text = File.read(queue_manager) + if text.include?(buggy_line) + File.chmod(0644, queue_manager) + File.write(queue_manager, text.sub(buggy_line, fixed_line)) + Pod::UI.puts "Patched SwiftAudioEx QueueManager.swift: shift current index when inserting into a one-item queue".green + elsif !text.include?(fixed_line) + raise "SwiftAudioEx QueueManager.swift no longer contains '#{buggy_line}'. Check whether the insert index fix is still needed and update the Podfile patch." + end + end end