GitHub Actions + XCTest + Pull Request Workflow for iOS
GitHub Actions + XCTest + Pull Request Workflow for iOS
Modern iOS development is not just writing Swift code. A production workflow usually includes automated builds, automated testing, Pull Requests, and CI pipelines that validate changes before merging them into the main branch.
This note walks through the mental model behind GitHub Actions, XCTest, Xcode schemes, test plans, and Pull Request workflows for iOS projects.
1. Why CI Exists
Imagine a team where every engineer directly pushes code into main.
Problems appear quickly:
1 | |
Continuous Integration (CI) exists to reduce these problems automatically.
The core idea:
1 | |
Usually this means:
1 | |
before code is merged into the main branch.
2. The High-Level Workflow
A modern Git workflow usually looks like this:
1 | |
Instead of committing directly to main, developers create feature branches.
For example:
1 | |
The engineer develops on this branch:
1 | |
Then opens a Pull Request:
1 | |
The Pull Request becomes the review and validation layer.
3. What Happens During a Pull Request
When a Pull Request is opened, GitHub Actions can automatically run CI workflows.
Typical iOS CI steps:
1 | |
If the workflow fails:
1 | |
This creates a safety gate around the main branch.
4. GitHub Actions Mental Model
GitHub Actions is event-driven automation.
A workflow is usually stored here:
1 | |
Example:
1 | |
This means:
1 | |
The workflow defines jobs:
1 | |
Important detail:
1 | |
5. xcodebuild
Most iOS CI systems eventually use:
1 | |
Example:
1 | |
This compiles the application.
Testing uses:
1 | |
Important distinction:
| Command | Purpose |
|---|---|
| build | Compile the project |
| test | Compile + execute XCTest |
6. XCTest
XCTest is Apple’s native testing framework.
Simple example:
1 | |
The key idea:
1 | |
If the expectation fails:
1 | |
This allows automated validation without manual checking.
7. Shared Schemes
One common iOS CI issue:
1 | |
Often the problem is:
1 | |
GitHub Actions only sees:
1 | |
not local user-specific schemes:
1 | |
The scheme must:
1 | |
Otherwise:
1 | |
appears.
8. Test Plans
Modern Xcode versions increasingly use Test Plans.
A test plan defines:
1 | |
Instead of directly attaching test targets to schemes, the flow is now often:
1 | |
This is why newer Xcode projects may contain:
1 | |
files.
9. Deployment Target Problems
Another common CI issue:
1 | |
Example:
1 | |
The fix:
1 | |
This happens because GitHub Actions runners may not match the newest local Xcode/macOS environment.
10. Why Pull Requests Matter
Pull Requests are not just for merging code.
They provide:
1 | |
Typical workflow:
1 | |
Most modern engineering teams avoid directly pushing to main.
11. CI Failure as Feedback
One useful mental model:
1 | |
It continuously checks:
1 | |
A failing CI pipeline is not necessarily bad.
Often it simply means:
1 | |
which is the entire purpose of CI.
12. Final Mental Model
GitHub Actions is not specifically an iOS technology.
It is:
1 | |
combined with:
1 | |
A modern iOS workflow usually becomes:
1 | |
The goal is not just automation.
The goal is maintaining code quality as teams and projects grow.