Section 7/171 menit

7. Build Actions dan Konfigurasi Skema

7. Build Actions dan Konfigurasi Skema

Build Action

swift
Build Action:
├── Scheme: MyApp (scheme yang dikonfigurasi untuk CI)
├── Platform: iOS, macOS, watchOS, tvOS, visionOS
└── Configuration: Debug / Release

Untuk CI, pastikan scheme dikonfigurasi dengan benar di Xcode:

swift
Xcode  Product  Scheme  Edit Scheme
└── Build
    ├── Analyze During Build: 
    └── Shared:    WAJIB agar Xcode Cloud bisa melihat scheme

Test Action

swift
Test Action:
├── Scheme: MyApp (harus include Test targets)
├── TestPlan: AllTests.xctestplan (opsional, untuk konfigurasi granular)
└── Destination:
    ├── Simulated  iPhone 15, iOS 17.x (simulasi di build environment)
    └── Recommended Destinations (Apple pilihkan otomatis)

Archive Action

Archive menghasilkan .ipa yang siap distribusi:

swift
Archive Action:
├── Scheme: MyApp
├── Configuration: Release
├── Code Signing: Automatic (dikelola Xcode Cloud)
└── Export Method:
    ├── App Store Connect (untuk TestFlight/App Store)
    └── Development (untuk internal testing)

TestPlan untuk Kontrol Granular

.xctestplan memungkinkan konfigurasi test yang detail:

swift
// AllTests.xctestplan
{
  "configurations": [
    {
      "id": "unit-tests",
      "name": "Unit Tests",
      "options": {
        "codeCoverageEnabled": true,
        "targetForVariableExpansion": { "name": "MyApp" }
      }
    }
  ],
  "defaultOptions": {
    "codeCoverageEnabled": true,
    "maximumTestExecutionTimeAllowance": 60,
    "testTimeoutsEnabled": true
  },
  "testTargets": [
    {
      "target": { "name": "MyAppTests" },
      "enabled": true
    },
    {
      "target": { "name": "MyAppUITests" },
      "enabled": true,
      "skippedTests": ["SlowSmokeTests"]
    }
  ],
  "version": 1
}