Section 11/151 menit
11. Troubleshooting & Masalah Umum
11. Troubleshooting & Masalah Umum
CocoaPods: "The sandbox is not in sync"
swift
# Error: The sandbox is not in sync with the Podfile.lock.
# Run 'pod install' or update your CocoaPods installation.
# Penyebab: Podfile.lock berbeda dengan Manifest.lock di Pods/
# Fix:
pod install
# Jika masih error:
pod deintegrate
pod install
CocoaPods: Duplicate Symbols
swift
# Error: duplicate symbol '_OBJC_CLASS_$_...'
# Penyebab: library yang sama di-include dua kali (atau CocoaPods + SPM)
# Fix 1: Cek apakah ada library yang sama di Podfile dan SPM
# Fix 2: Jika pakai use_frameworks! dengan beberapa static pods yang conflict:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# Force semua pod menjadi static atau dynamic konsisten
config.build_settings['MACH_O_TYPE'] = 'staticlib'
end
end
end
SPM: "dependency graph is unresolvable"
swift
# Error: dependency graph is unresolvable
# Penyebab: dua package butuh versi berbeda dari dependency yang sama
# Fix 1: Update semua package ke versi terbaru
swift package update
# Fix 2: Reset Package.resolved dan resolve ulang
rm Package.resolved
swift package resolve
# Fix 3: Pinpoint conflict
swift package show-dependencies --format json | python3 -c "
import json, sys
data = json.load(sys.stdin)
# Cari package yang muncul lebih dari sekali dengan versi berbeda
"
SPM: Package Build Lama di CI
swift
# Problem: SPM resolve dan build sangat lama di CI (tidak ada cache)
# Fix 1: Tambahkan cache seperti di seksi 8
# Fix 2: Pre-resolve dengan xcodebuild
xcodebuild -resolvePackageDependencies \
-project MyApp.xcodeproj \
-derivedDataPath DerivedData
# Fix 3: Gunakan binary targets untuk packages besar
# Convert source dependency ke pre-compiled .xcframework
Hybrid: "Multiple commands produce"
swift
# Error: Multiple commands produce '/path/to/SomeFramework.framework'
# Penyebab: Framework yang sama di-include via CocoaPods DAN SPM
# Fix: Hapus dari salah satu
# Cek di Podfile: apakah ada pod yang sama dengan SPM package?
# Cek di Xcode SPM panel: apakah ada package yang juga di Podfile?
M1 Mac: CocoaPods Architecture Issue
swift
# Error: ld: warning: ignoring file .../SomePod.framework,
# file was built for archive which is not the architecture being linked
# Fix 1: Jalankan pod install dengan Rosetta
arch -x86_64 pod install
# Fix 2: exclude arm64 di Podfile (untuk pods yang belum support Apple Silicon)
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
# Fix 3 (terbaik): Tunggu pod support Apple Silicon native, atau pindah ke SPM