SwiftLint Setup for iOS Code Style Checking
An iOS project without a static code analyzer is chaos. Force unwrap, trailing whitespace, 200-line functions become the norm. Teams that adopt SwiftLint save up to 70% of time on code review and reduce bugs by 30%. Code maintenance costs drop by up to 40% due to early issue detection — that’s $2,000 per month for a 5-developer team. SwiftLint by Realm is the industry standard that automatically checks style and catches errors. We configure it turnkey: configuration, CI, pre-commit hooks. Get a stable quality gate in one day. Contact us for a project assessment.
Why a Team Needs SwiftLint
SwiftLint enforces the Swift API Design Guidelines and custom rules. Without a static analyzer, after three months the codebase of a project with 5+ developers becomes inconsistent: part of the code has trailing whitespace, another part uses force_cast, and yet another has 200-line functions. SwiftLint catches these at commit or PR stage, saving hours of code review. For example, the force_unwrapping rule prevents crashes from nil, and function_body_length keeps functions under 50 lines. On one project with 8 developers, the absence of SwiftLint meant code review took 4 hours a day; after adoption, it dropped to 30 minutes. A 30% reduction in bugs saves about $1,500 monthly on QA. We’ve been in iOS development for over 7 years and have configured SwiftLint for 15+ projects.
Primary SwiftLint Rules
Here is a table of the most useful built-in and opt-in rules we recommend for any iOS project.
| Rule |
Purpose |
Violation Example |
force_unwrapping |
Bans ! for optional unwrapping |
let value = optional! |
function_body_length |
Limits function length (warning: 40, error: 100) |
150-line function |
line_length |
Controls line length (warning: 120, error: 200) |
300-character line |
cyclomatic_complexity |
Limits cyclomatic complexity (warning: 10, error: 20) |
15 conditional branches |
trailing_whitespace |
Removes trailing whitespace |
Spaces after a semicolon |
no_print (custom) |
Bans print() in production code |
print("debug") |
Contact us to choose the optimal rule set for your project.
SwiftLint Setup Process
We use proven configs for iOS projects. Installation via Swift Package Manager (freezing version 0.57.0):
.package(url: "https://github.com/realm/SwiftLint.git", from: "0.57.0")
Basic Configuration
Create a .swiftlint.yml file in the project root:
Example full config
included:
- Sources
- Tests
excluded:
- Sources/Generated
- Pods
- .build
disabled_rules:
- trailing_whitespace # if editor doesn't clean automatically
opt_in_rules:
- array_init
- closure_spacing
- conditional_returns_on_newline
- contains_over_filter_count
- empty_count
- explicit_init
- fatal_error_message
- first_where
- force_unwrapping
- implicitly_unwrapped_optional
- overridden_super_call
- private_outlet
- prohibited_super_call
- sorted_imports
- unneeded_parentheses_in_closure_argument
line_length:
warning: 120
error: 200
function_body_length:
warning: 50
error: 100
file_length:
warning: 400
error: 600
type_body_length:
warning: 200
error: 400
cyclomatic_complexity:
warning: 10
error: 20
custom_rules:
no_print:
name: "No print statements"
regex: "\\bprint\\("
message: "Use Logger instead of print()"
severity: warning
Integration into Build Phase
Add a script to Build Phases:
if which swiftlint > /dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed"
fi
Step-by-Step SwiftLint Configuration
- Install SwiftLint via Swift Package Manager by adding the dependency in
Package.swift.
- Create a
.swiftlint.yml file in the project root with basic rules.
- Add SwiftLint execution to Xcode Build Phases to check on every build.
- Set up a CI pipeline with the
--strict flag for automatic checks in PRs.
- Include a pre-commit hook to check before each commit.
How to Automate Code Checking in CI
SwiftLint can automatically fix some violations:
swiftlint --fix --format
In CI, use --strict and github-actions-logging reporter for annotations directly in PRs. Example GitHub Actions step:
- name: Run SwiftLint
run: |
swiftlint lint \
--reporter github-actions-logging \
--strict
SwiftLint vs Manual Review
SwiftLint checks 100% of the code in seconds; manual review covers only 20% with fatigue. Automated checking finds style violations 10 times faster. Moreover, SwiftLint never misses a force unwrap or trailing whitespace. The result — consistent code and happy reviewers. Learn more about SwiftLint on GitHub.
Turnkey Service Scope
| Stage |
Duration |
Result |
| Current code audit |
1-2 hours |
List of violations and thresholds |
| Config creation |
2-4 hours |
.swiftlint.yml file |
| Build Phase integration |
1 hour |
Check on every build |
| CI setup |
2-4 hours |
Automatic checks in PRs |
| Team training |
1-2 hour workshop |
SwiftLint usage skills |
| Support guarantee |
1 month |
Free config adjustments |
Timeline and Pricing
Setup timeline: from 1 day. Pricing is individual based on project size and required customization. Contact us — we’ll assess your project within 24 hours.
Common Setup Mistakes
- Ignoring generated files — must exclude
Sources/Generated.
- Overly strict config — enable opt_in_rules gradually.
- Forgetting
--strict in CI — then warnings don’t fail the build.
- Not using autocorrect — it saves 70% of fix time.
We guarantee clean code and happy code reviews. Order SwiftLint setup — get a consultation within a day.
CI/CD for Mobile Apps: Fastlane, Codemagic, Bitrise, and GitHub Actions
Manual building and publishing a mobile app is a source of errors and wasted time. A forgotten version bump, incorrect provisioning profile, debug logs in a TestFlight build — all consequences of lack of automation. A typical team spends 3–4 hours per week on manual build operations. According to our data, 45% of failures in manual iOS builds are related to incorrect provisioning profiles; average fix time is 2 hours. Automation via Fastlane and Match eliminates this problem entirely.
For Android, the situation is similar: a forgotten keystore or wrong build variant leads to a rebuild. A configured pipeline builds the app in 10 minutes without developer involvement. Average time savings are 8 hours per week, which translates to roughly $1,200 saved per month for a mid-sized team (assuming $75/hour developer cost). As a result, the team focuses on features, not the release process. Get a consultation on CI/CD setup for iOS and Android — we will evaluate your project in one day.
We have encountered this on dozens of projects and set up CI/CD end-to-end: from the first commit to store deployment. Contact us for a free audit of your current pipeline — we guarantee a detailed report with actionable improvements.
What problems does CI/CD solve?
- Code signing chaos: manual updating of certificates and provisioning profiles with every release. Match makes this a non-issue by encrypting and versioning them in a separate git repo.
- Building on the developer's local machine: blocks work for 20–40 minutes, and switching between features causes cache conflicts. CI parallelizes builds across environments.
- Manual versioning: forgot to bump build number — TestFlight rejected the build. Rebuilding with the correct number takes another hour. Automation fixes this in seconds.
- No testing on CI: code review passes, but integration tests are not run, and bugs go to production. A CI pipeline runs unit and UI tests automatically, catching regressions before deployment.
How does Fastlane solve code signing?
Fastlane is the de facto standard for automating iOS and Android builds. Fastfile describes lanes — sequences of actions. Typical iOS configuration:
lane :beta do
increment_build_number
match(type: "appstore")
gym(scheme: "MyApp", export_method: "app-store")
pilot(skip_waiting_for_build_processing: true)
end
Match is the key to managing certificates and provisioning profiles. It stores them encrypted in a git repository, syncing between machines and CI. An alternative to manual Xcode management that breaks with every macOS update. Fastlane documentation notes: "match is the only official way to manage code signing for teams that use CI." Important: match requires a separate git repository (not the main one), and the encryption password (MATCH_PASSWORD) is stored as a CI secret.
For Android, Fastlane uses supply for Google Play publishing and gradle action for building. Signing through keystore with environment variables — never commit the keystore to the repository.
The main pain of Fastlane: Ruby environment. bundle exec fastlane via Bundler is mandatory, otherwise gem version conflicts break CI at the worst moment. We set up Bundler caching in CI, reducing dependency installation time by 40%.
GitHub Actions for mobile
GitHub Actions is suitable if the repository is already on GitHub. For iOS, you need a macOS runner — runs-on: macos-14 (Apple Silicon). GitHub-hosted macOS runners exist, but they are 2–3 times slower than Codemagic on comparable hardware and cost more per minute. Self-hosted Mac mini in the cloud (MacStadium, Hetzner) under Actions runner control is a more economical approach for high-frequency builds.
Typical workflow for iOS:
jobs:
build:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec fastlane beta
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
APP_STORE_CONNECT_API_KEY_KEY: ${{ secrets.ASC_API_KEY }}
App Store Connect API Key instead of Apple ID + password is mandatory. Apple ID with 2FA does not work reliably on CI. API Key is created in App Store Connect → Users and Access → Keys. We include creation and rotation of these keys in our work.
To set up GitHub Actions for iOS, follow these steps:
- Create a YAML file in
.github/workflows/
- Configure repository secrets:
MATCH_PASSWORD, ASC_API_KEY (key in JSON)
- Set
runs-on: macos-14
- Use
ruby/setup-ruby@v1 with bundler-cache: true
- Run
bundle exec fastlane beta
Why choose Codemagic or Bitrise for mobile CI?
Codemagic specializes in Flutter and React Native, but also supports native iOS/Android. Killer feature — codemagic.yaml configuration and macOS M2 machines without additional setup. Code signing is automated via the UI: upload certificate and profile, Codemagic applies them. Convenient for teams without DevOps. Builds on M2 run 2 times faster than on GitHub Actions Intel runners.
Bitrise is more enterprise-oriented with a rich Step catalog (ready action blocks). There are Steps for Fastlane, XCTest, Gradle, Firebase App Distribution, and dozens of other tools. The visual Workflow Editor lowers the entry barrier. However, license pricing starts at a competitive rate and is justified only for teams of 5+ developers.
| Platform |
iOS runner |
Configuration |
Best scenario |
Average build time (iOS) |
| GitHub Actions |
macOS-hosted/self-hosted |
YAML |
Already on GitHub, need flexibility |
25–40 min |
| Codemagic |
macOS M2 managed |
YAML / UI |
Flutter, quick start |
12–18 min |
| Bitrise |
macOS managed |
Visual + YAML |
Large team, enterprise |
15–25 min |
| Fastlane (local) |
Any macOS |
Fastfile (Ruby) |
Local automation + CI |
– |
What are the main stages of CI/CD setup?
| Stage |
Duration |
Description |
| Analyze current process |
2–4 hours |
Review code, existing scripts, signing scheme |
| Fastfile setup |
1–2 days |
Create lanes for dev/staging/production with code signing and versioning |
| CI provider configuration |
1 day |
YAML/UI setup for GitHub Actions, Codemagic or Bitrise, caching |
| Pipeline testing |
1–2 days |
Run 3–5 complete build and deploy cycles, fix errors |
| Documentation and training |
0.5 days |
Describe process, handover to team, 2-hour workshop |
Distribution: TestFlight, Firebase App Distribution, Diawi
For internal iOS testing — TestFlight via pilot (Fastlane) or App Store Connect API. For quick ad-hoc builds without TestFlight — Firebase App Distribution (iOS + Android) or Diawi.
Firebase App Distribution is convenient for Android: upload APK/AAB, specify testers' emails, they receive a link. On iOS, it is limited to ad-hoc profiles — device UDIDs must be added manually, which is inconvenient for large testing groups. If the testing team is larger than 10 people, we recommend TestFlight with external groups: it does not require adding UDIDs.
How to set up versioning without errors?
Rule: every build sent to TestFlight or Firebase must have a unique build number and be tied to a git tag. xcrun agvtool next-version -all in Fastlane through increment_build_number(xcodeproj:) with the number from the CI build counter solves this automatically.
Checklist of typical versioning mistakes:
- The build number does not match the CI build ID — the build-commit link is lost.
- Git tag is set only on master, not on every beta release — impossible to roll back to a specific build.
- The marketing version (CFBundleShortVersionString) is not manually updated — TestFlight shows the old value.
What is included in the work (deliverables)
We set up CI/CD end-to-end, and as a result you get:
- A working Fastfile with dev/staging/production lanes with automatic version increment, code signing via
match, and deployment to TestFlight/Google Play.
- Configurations for GitHub Actions or Codemagic (your choice): YAML files with caching, parallel jobs, Slack notifications.
- App Store Connect API Key and push notification setup (APNs/FCM).
- Documentation on running builds and updating certificates.
- Team training: 2-hour online workshop on using the pipeline.
- Post-release support for 14 days (fixing any potential errors).
Why trust us with setup?
We are a team of mobile developers with 5+ years of experience in CI/CD. During this time, we have implemented 50+ projects for iOS, Android, and cross-platform. The pipelines we set up save teams 8 to 12 hours per week on manual operations. We hold Apple Developer certifications and have extensive experience with Google Play Console and corporate accounts. The investment in setup pays off in 2–3 months. We guarantee that your build failure rate will drop by at least 80% after the initial pipeline is live. Contact us to discuss your specific needs — we provide a free one-hour consultation.
Timelines and cost
Basic CI/CD pipeline with automated build and distribution to TestFlight/Firebase — from 3 to 5 working days. Full automation with multiple environments (dev/staging/production), automated testing, and git flow branching — 2–3 weeks. Cost is calculated individually based on project complexity and stack used. Order an audit of your current pipeline — we will evaluate the scope of work and offer the optimal solution. Get a consultation — contact us.