CI/CD Setup Generator
Generate CI/CD configuration for automated builds, tests, and distribution of iOS/macOS apps.
When This Skill Activates
- User wants to automate their build and test process
- User mentions GitHub Actions, Xcode Cloud, or fastlane
- User wants to set up TestFlight or App Store deployment
- User asks about continuous integration for their app
Pre-Generation Checks
Before generating, verify:
Existing CI Configuration
# Check for existing CI files
ls -la .github/workflows/ 2>/dev/null
ls -la ci_scripts/ 2>/dev/null
ls -la fastlane/ 2>/dev/null
Project Structure
# Find Xcode project/workspace
find . -name "*.xcodeproj" -o -name "*.xcworkspace" | head -5
Package Manager
# Check for SPM vs CocoaPods
ls Package.swift 2>/dev/null
ls Podfile 2>/dev/null
Configuration Questions
1. CI/CD Platform
- GitHub Actions (Recommended) - Full control, extensive marketplace
- Xcode Cloud - Native Apple integration, simpler setup
- Both - GitHub for PRs/tests, Xcode Cloud for releases
2. Distribution Method
- TestFlight - Beta testing via App Store Connect
- App Store - Production releases
- Direct (macOS only) - Notarized DMG/PKG distribution
- All - Full pipeline from dev to production
3. Include fastlane?
- Yes - Advanced automation, match for code signing
- No - Simpler setup using xcodebuild directly
4. Code Signing Approach
- Manual - Certificates in GitHub Secrets
- match (fastlane) - Git-based certificate management
- Xcode Cloud Managed - Apple handles signing
Generated Files
GitHub Actions
.github/workflows/
├── build-test.yml # PR checks, unit tests
├── deploy-testflight.yml # TestFlight deployment
└── deploy-appstore.yml # App Store submission
Xcode Cloud
ci_scripts/
├── ci_post_clone.sh # Post-clone setup
└── ci_pre_xcodebuild.sh # Pre-build configuration
fastlane
fastlane/
├── Fastfile # Lane definitions
├── Appfile # App configuration
└── Matchfile # Code signing (if using match)
SwiftLint
.swiftlint.yml # from templates/swiftlint/swiftlint.yml
Merging Skill Rule Fragments
Skills in this library may ship graduated enforcement as a
rules/swiftlint.yml fragment (opt_in_rules + custom_rules) — prose
rules turned into deterministic lint. When generating .swiftlint.yml:
- Start from
templates/swiftlint/swiftlint.yml.
- For each skill the project actually uses, check for
skills/<category>/<skill>/rules/swiftlint.yml; append its
custom_rules entries and union its opt_in_rules.
- Respect fragment scoping comments — e.g.
observable_object_legacy
applies only to iOS 17+/macOS 14+ deployment targets, and
xctest_in_unit_tests must keep its UITests exclusion (XCUITest
legitimately requires XCTest).
- The generated
build-test.yml runs the lint job automatically once
.swiftlint.yml exists (if: hashFiles('.swiftlint.yml') != '').
Current fragments: security/ (hardcoded secrets), ios/coding-best-practices
(print-in-production, legacy ObservableObject, force_unwrapping/force_try),
testing/tdd-feature (XCTest scoped out of unit tests),
swift/concurrency (@unchecked Sendable without justification).
Integration Steps
GitHub Actions Setup
Add Repository Secrets (Settings > Secrets and variables > Actions):
APP_STORE_CONNECT_API_KEY_ID - API Key ID
APP_STORE_CONNECT_API_ISSUER_ID - Issuer ID
APP_STORE_CONNECT_API_KEY_CONTENT - Private key (.p8 content)
CERTIFICATE_P12 - Base64-encoded .p12 certificate
CERTIFICATE_PASSWORD - Certificate password
PROVISIONING_PROFILE - Base64-encoded provisioning profile
Create App Store Connect API Key:
- Go to App Store Connect > Users and Access > Keys
- Generate API Key with "App Manager" role
- Download the .p8 file (only available once)
Export Certificate:
# Export from Keychain as .p12, then base64 encode
base64 -i certificate.p12 | pbcopy
Xcode Cloud Setup
Enable Xcode Cloud in Xcode:
- Product > Xcode Cloud > Create Workflow
- Connect to App Store Connect
Configure Workflow:
- Set start conditions (branch, PR, tag)
- Configure environment variables
- Set up post-actions (TestFlight, App Store)
Add ci_scripts to repository for customization
fastlane Setup
Install fastlane:
brew install fastlane
Initialize (if starting fresh):
fastlane init
Set up match (optional, for code signing):
fastlane match init
fastlane match development
fastlane match appstore
Best Practices
Caching
- Cache Swift Package Manager dependencies
- Cache DerivedData for faster builds
- Use selective caching to avoid stale artifacts
Secrets Management
- Never commit certificates or keys
- Use environment variables for sensitive data
- Rotate API keys periodically
Build Optimization
- Use incremental builds where possible
- Parallelize test execution
- Skip unnecessary steps on draft PRs
Notifications
- Slack/Discord integration for build status
- Email notifications for failures
- GitHub status checks for PRs
References
1---
2name: ci-cd-setup
3description: Generate CI/CD configuration for automated builds, tests, and distribution of iOS/macOS apps. Use when setting up GitHub Actions, Xcode Cloud, or fastlane for continuous integration, TestFlight, or App Store deployment.
4allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion]
5last_verified: 2026-07-16
6review_by: 2027-06-22
7---
8
9# CI/CD Setup Generator
10
11Generate CI/CD configuration for automated builds, tests, and distribution of iOS/macOS apps.
12
13## When This Skill Activates
14
15- User wants to automate their build and test process
16- User mentions GitHub Actions, Xcode Cloud, or fastlane
17- User wants to set up TestFlight or App Store deployment
18- User asks about continuous integration for their app
19
20## Pre-Generation Checks
21
22Before generating, verify:
23
241. **Existing CI Configuration**
25 ```bash
26 # Check for existing CI files
27 ls -la .github/workflows/ 2>/dev/null
28 ls -la ci_scripts/ 2>/dev/null
29 ls -la fastlane/ 2>/dev/null
30 ```
31
322. **Project Structure**
33 ```bash
34 # Find Xcode project/workspace
35 find . -name "*.xcodeproj" -o -name "*.xcworkspace" | head -5
36 ```
37
383. **Package Manager**
39 ```bash
40 # Check for SPM vs CocoaPods
41 ls Package.swift 2>/dev/null
42 ls Podfile 2>/dev/null
43 ```
44
45## Configuration Questions
46
47### 1. CI/CD Platform
48- **GitHub Actions** (Recommended) - Full control, extensive marketplace
49- **Xcode Cloud** - Native Apple integration, simpler setup
50- **Both** - GitHub for PRs/tests, Xcode Cloud for releases
51
52### 2. Distribution Method
53- **TestFlight** - Beta testing via App Store Connect
54- **App Store** - Production releases
55- **Direct** (macOS only) - Notarized DMG/PKG distribution
56- **All** - Full pipeline from dev to production
57
58### 3. Include fastlane?
59- **Yes** - Advanced automation, match for code signing
60- **No** - Simpler setup using xcodebuild directly
61
62### 4. Code Signing Approach
63- **Manual** - Certificates in GitHub Secrets
64- **match** (fastlane) - Git-based certificate management
65- **Xcode Cloud Managed** - Apple handles signing
66
67## Generated Files
68
69### GitHub Actions
70```
71.github/workflows/
72├── build-test.yml # PR checks, unit tests
73├── deploy-testflight.yml # TestFlight deployment
74└── deploy-appstore.yml # App Store submission
75```
76
77### Xcode Cloud
78```
79ci_scripts/
80├── ci_post_clone.sh # Post-clone setup
81└── ci_pre_xcodebuild.sh # Pre-build configuration
82```
83
84### fastlane
85```
86fastlane/
87├── Fastfile # Lane definitions
88├── Appfile # App configuration
89└── Matchfile # Code signing (if using match)
90```
91
92### SwiftLint
93```
94.swiftlint.yml # from templates/swiftlint/swiftlint.yml
95```
96
97## Merging Skill Rule Fragments
98
99Skills in this library may ship graduated enforcement as a
100`rules/swiftlint.yml` fragment (`opt_in_rules` + `custom_rules`) — prose
101rules turned into deterministic lint. When generating `.swiftlint.yml`:
102
1031. Start from `templates/swiftlint/swiftlint.yml`.
1042. For each skill the project actually uses, check for
105 `skills/<category>/<skill>/rules/swiftlint.yml`; append its
106 `custom_rules` entries and union its `opt_in_rules`.
1073. Respect fragment scoping comments — e.g. `observable_object_legacy`
108 applies only to iOS 17+/macOS 14+ deployment targets, and
109 `xctest_in_unit_tests` must keep its UITests exclusion (XCUITest
110 legitimately requires XCTest).
1114. The generated `build-test.yml` runs the `lint` job automatically once
112 `.swiftlint.yml` exists (`if: hashFiles('.swiftlint.yml') != ''`).
113
114Current fragments: `security/` (hardcoded secrets), `ios/coding-best-practices`
115(print-in-production, legacy ObservableObject, force_unwrapping/force_try),
116`testing/tdd-feature` (XCTest scoped out of unit tests),
117`swift/concurrency` (@unchecked Sendable without justification).
118
119## Integration Steps
120
121### GitHub Actions Setup
122
1231. **Add Repository Secrets** (Settings > Secrets and variables > Actions):
124 - `APP_STORE_CONNECT_API_KEY_ID` - API Key ID
125 - `APP_STORE_CONNECT_API_ISSUER_ID` - Issuer ID
126 - `APP_STORE_CONNECT_API_KEY_CONTENT` - Private key (.p8 content)
127 - `CERTIFICATE_P12` - Base64-encoded .p12 certificate
128 - `CERTIFICATE_PASSWORD` - Certificate password
129 - `PROVISIONING_PROFILE` - Base64-encoded provisioning profile
130
1312. **Create App Store Connect API Key**:
132 - Go to App Store Connect > Users and Access > Keys
133 - Generate API Key with "App Manager" role
134 - Download the .p8 file (only available once)
135
1363. **Export Certificate**:
137 ```bash
138 # Export from Keychain as .p12, then base64 encode
139 base64 -i certificate.p12 | pbcopy
140 ```
141
142### Xcode Cloud Setup
143
1441. **Enable Xcode Cloud** in Xcode:
145 - Product > Xcode Cloud > Create Workflow
146 - Connect to App Store Connect
147
1482. **Configure Workflow**:
149 - Set start conditions (branch, PR, tag)
150 - Configure environment variables
151 - Set up post-actions (TestFlight, App Store)
152
1533. **Add ci_scripts** to repository for customization
154
155### fastlane Setup
156
1571. **Install fastlane**:
158 ```bash
159 brew install fastlane
160 ```
161
1622. **Initialize** (if starting fresh):
163 ```bash
164 fastlane init
165 ```
166
1673. **Set up match** (optional, for code signing):
168 ```bash
169 fastlane match init
170 fastlane match development
171 fastlane match appstore
172 ```
173
174## Best Practices
175
176### Caching
177- Cache Swift Package Manager dependencies
178- Cache DerivedData for faster builds
179- Use selective caching to avoid stale artifacts
180
181### Secrets Management
182- Never commit certificates or keys
183- Use environment variables for sensitive data
184- Rotate API keys periodically
185
186### Build Optimization
187- Use incremental builds where possible
188- Parallelize test execution
189- Skip unnecessary steps on draft PRs
190
191### Notifications
192- Slack/Discord integration for build status
193- Email notifications for failures
194- GitHub status checks for PRs
195
196## References
197
198- [GitHub Actions for Xcode](https://github.com/actions/runner-images/blob/main/images/macos)
199- [Xcode Cloud Documentation](https://developer.apple.com/documentation/xcode/xcode-cloud)
200- [fastlane Documentation](https://docs.fastlane.tools)
201- [App Store Connect API](https://developer.apple.com/documentation/appstoreconnectapi)