Section 10/181 menit

10. Xcode Cloud: CI/CD Terintegrasi

10. Xcode Cloud: CI/CD Terintegrasi

Xcode Cloud adalah CI/CD Apple yang terintegrasi langsung di Xcode — tidak perlu setup server.

Setup Xcode Cloud

swift
1. Xcode → Product → Xcode Cloud → Create Workflow
2. Connect ke GitHub/GitLab/Bitbucket
3. Pilih branch trigger: main, feature/*, tag v*.*.*
4. Tambahkan environment variables (API keys, dll)
5. Configure post-action: notify Slack, TestFlight upload

ci_scripts: Custom Actions

swift
# ci_scripts/ — folder di root project untuk custom scripts

# ci_post_clone.sh — dijalankan setelah clone
#!/bin/sh
set -e

# Install dependencies yang tidak bisa via SPM
gem install bundler
bundle install

# Setup environment dari secrets
echo "BASE_URL=$BASE_URL" >> .env

# ci_post_xcodebuild.sh — dijalankan setelah build
#!/bin/sh
set -e

# Upload dSYMs ke crash reporting tool
if [ "$CI_XCODEBUILD_ACTION" = "archive" ]; then
  ./Scripts/upload_dsyms.sh "$CI_ARCHIVE_PATH"
fi
swift
# Tidak ada YAML config — Xcode Cloud dikonfigurasi via Xcode UI
# Tapi best practices:

# Workflows yang direkomendasikan:
# 1. PR Check:
#    - Trigger: setiap PR ke main
#    - Action: test (semua target)
#    - Tidak upload ke TestFlight
#
# 2. Nightly Beta:
#    - Trigger: scheduled (jam 2 pagi)
#    - Action: archive + TestFlight (internal)
#    - Notify: team via Slack
#
# 3. Release:
#    - Trigger: tag v*.*.*
#    - Action: archive + App Store Connect (manual review)
#    - Notify: PM via email