Section 2/181 menit

2. Masalah Lanjutan yang Dipecahkan

2. Masalah Lanjutan yang Dipecahkan

Masalah 1: Version Conflict yang Tidak Jelas

swift
// ❌ TANPA pemahaman resolver: version conflict misterius
// Error: "The package dependency graph cannot be resolved..."
// Package A requires LibX 1.2.0..<2.0.0
// Package B requires LibX 1.5.0..<1.8.0
// → SPM tidak tahu harus pilih versi berapa
swift
// ✓ DENGAN pemahaman resolver: identifikasi akar masalah
// Lihat Package.resolved untuk melihat versi yang terpilih
// Gunakan `swift package show-dependencies` untuk audit graph
// Gunakan exact version sebagai workaround sementara
.package(url: "https://github.com/example/LibX", exact: "1.6.0")

Masalah 2: Code Generation Manual yang Lambat

swift
// ❌ TANPA Build Plugin: generate kode secara manual
// 1. Jalankan script Python sebelum build
// 2. Commit file generated ke repo
// 3. Selalu ada risiko file generated tidak sinkron dengan source
// 4. Developer baru bingung mana file "asli" mana file generated
swift
// ✓ DENGAN Build Tool Plugin: generate otomatis saat build
// Plugin berjalan setiap build, output masuk sandbox folder
// Developer tidak perlu commit file generated
// Source of truth tunggal: template/schema asli

Masalah 3: Distribusi Library dengan Source Code Terbuka

swift
// ❌ TANPA binary target: distribusi library dengan source code
// - Competitor bisa melihat implementasi proprietary
// - Build time konsumen meningkat (compile semua source)
// - Tidak bisa distribute library yang ada dependency berbayar
swift
// ✓ DENGAN XCFramework + binary target:
// - Source code tersembunyi
// - Build time konsumen berkurang drastis (pre-compiled)
// - Satu binary untuk semua platform (iOS device, simulator, macOS)
.binaryTarget(
    name: "ProprietarySDK",
    url: "https://cdn.example.com/ProprietarySDK-1.0.0.zip",
    checksum: "abc123..."
)