Section 3/101 menit
3. Konfigurasi di Xcode
3. Konfigurasi di Xcode
3.1 Set Swift Language Version per Target
swift
Xcode → Project → Target → Build Settings
└── Cari: "Swift Language Version"
├── Pilih "Swift 5" → tetap Swift 5
└── Pilih "Swift 6" → aktifkan Swift 6 mode
Screenshot path di Build Settings:
swift
Build Settings
├── Swift Compiler - Language
│ ├── Swift Language Version [Swift 5] ← ubah ini
│ └── ...
└── Swift Compiler - Upcoming Features
├── Strict Concurrency Checking [Minimal/Targeted/Complete]
└── ...
3.2 Strict Concurrency Checking (Tanpa Full Swift 6)
Untuk dapat warning concurrency tanpa mengaktifkan Swift 6 sepenuhnya:
swift
Build Settings → Swift Compiler - Upcoming Features
└── Strict Concurrency Checking
├── Minimal → hanya warning minimal (hampir tidak ada)
├── Targeted → warning pada kode yang jelas concurrent ← REKOMENDASI untuk migrasi
└── Complete → semua warning Swift 6 (tapi masih warning, bukan error)
Setara di xcconfig atau Other Swift Flags:
swift
// xcconfig file
SWIFT_STRICT_CONCURRENCY = targeted
3.3 Aktifkan Upcoming Features Satu per Satu di Xcode
Di Other Swift Flags (Build Settings):
swift
OTHER_SWIFT_FLAGS = -enable-upcoming-feature StrictConcurrency
-enable-upcoming-feature TypedThrows
-enable-upcoming-feature ExistentialAny
Atau di .xcconfig:
swift
// MyApp.xcconfig
OTHER_SWIFT_FLAGS = $(inherited) -enable-upcoming-feature StrictConcurrency
3.4 Struktur Target yang Direkomendasikan untuk Migrasi
swift
MyApp (Xcode Project)
├── MyApp Target → SWIFT_VERSION = 5 (UI layer, belum disentuh)
├── MyAppCore Target → SWIFT_VERSION = 6 (business logic, sudah dimigrasikan)
│ └── Dependencies: MyAppLegacy
├── MyAppLegacy Target → SWIFT_VERSION = 5 (kode lama yang belum dimigrasikan)
└── MyAppTests Target → SWIFT_VERSION = 6 (test baru pakai Swift Testing)