Reapply "Capacitor 8 — Step B: migrate iOS from CocoaPods to Swift Package Manager"

This reverts commit 166bea4314.
This commit is contained in:
2026-08-03 15:52:46 +05:30
parent 166bea4314
commit 7f54182186
7 changed files with 110 additions and 56 deletions
+5 -40
View File
@@ -123,46 +123,11 @@ if [ -f "$AD" ]; then
node "$(dirname "$0")/inject-push.js" "$AD" || echo " (push forwarding patch skipped — non-fatal)"
fi
# ── Pin LiveKit to 2.15.3 via its Git tag (stay on CocoaPods; no SPM migration) ─────────────────────
# The CallKit audio-session coordination API (AudioManager.audioSession / setEngineAvailability) exists only
# in LiveKit 2.1+, but the LiveKitClient CocoaPod PUBLISHED to trunk caps at 2.0.18 (2.1+ is SPM-only). The
# repo still ships a VALID podspec at tag 2.15.3, and its deps (LiveKitWebRTC 144.7559.11 / LiveKitUniFFI
# 0.0.6 / SwiftProtobuf) ARE on trunk — so we point the Podfile straight at the git tag. The NativeCall
# podspec's `LiveKitClient ~> 2.0` is satisfied by 2.15.3 (2.15.3 ∈ [2.0, 3.0)). Idempotent (grep guard).
PODFILE="mobile/ios/App/Podfile"
if [ -f "$PODFILE" ]; then
if grep -q "client-sdk-swift.git" "$PODFILE"; then
echo "Podfile: LiveKitClient git pin already present"
else
ruby -e '
p = "mobile/ios/App/Podfile"
s = File.read(p)
# LiveKit 2.15.3 pulls two binary deps that are SPM-only (NOT on the CocoaPods CDN), so we pin each to
# its own repo podspec (neither has further deps):
# * LiveKitUniFFI 0.0.6 — podspec has a :git source + prepare_command that downloads its xcframework, so :git works.
# * LiveKitWebRTC 144.7559.11 — podspec has an :http source (release-zip), NOT in the git tree, so we
# point at the podspec URL with :podspec (using :git would clone a repo with no xcframework and fail).
# SwiftProtobuf (the only other dep) resolves from the CDN normally.
pin = " pod \x27LiveKitClient\x27, :git => \x27https://github.com/livekit/client-sdk-swift.git\x27, :tag => \x272.15.3\x27\n" +
" pod \x27LiveKitUniFFI\x27, :git => \x27https://github.com/livekit/livekit-uniffi-xcframework.git\x27, :tag => \x270.0.6\x27\n" +
" pod \x27LiveKitWebRTC\x27, :podspec => \x27https://raw.githubusercontent.com/livekit/webrtc-xcframework/144.7559.11/LiveKitWebRTC.podspec\x27\n"
if s =~ /target ["\x27]App["\x27] do\n/
s = s.sub(/target ["\x27]App["\x27] do\n/) { |m| m + pin }
File.write(p, s)
puts "Podfile: pinned LiveKitClient 2.15.3 + LiveKitUniFFI 0.0.6 + LiveKitWebRTC 144.7559.11"
else
STDERR.puts "WARN: could not find \"target App do\" in Podfile — LiveKit pin NOT applied"
exit 1
end
'
fi
grep -n "LiveKitClient" "$PODFILE" || true
# `npx cap sync` already ran `pod install` with the PRE-pin Podfile, leaving a Podfile.lock that pins
# LiveKitClient = 2.0.18 — which conflicts with the git-tag source we just injected ("could not find
# compatible versions … In snapshot (Podfile.lock): LiveKitClient (= 2.0.18)"). Drop the lock so the
# later "Install CocoaPods" step re-resolves cleanly against tag 2.15.3.
rm -f "mobile/ios/App/Podfile.lock" && echo "Removed stale Podfile.lock (cap-sync pinned 2.0.18)"
fi
# ── LiveKit under SPM (Capacitor 8) ─────────────────────────────────────────────────────────────────
# LiveKit is now a proper Swift Package Manager dependency declared in the native-call plugin's Package.swift
# (github.com/livekit/client-sdk-swift, exact 2.15.3) — SPM resolves it + its WebRTC/UniFFI/SwiftProtobuf
# sub-packages at build time. So there is NO Podfile to patch here anymore (the old CocoaPods git-tag pin
# hack is gone).
echo "Info.plist patched:"
"$PB" -c "Print :NSCameraUsageDescription" "$PLIST"