iOS Development
iOS development within the SMI ecosystem follows the “PWA First” strategy, but utilizes native shells ( Capacitor/Cordova) or pure native code (Swift) when platform-specific limitations are encountered.
Information
iOS is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company’s mobile devices, including the iPhone and iPad.
Installation
iOS development requires macOS.
- Xcode: Install the latest version of Xcode from the Mac App Store.
- Xcode Command Line Tools:
xcode-select --install - Homebrew: Recommended for managing dependencies.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - CocoaPods: (If using Cordova or older plugins)
sudo gem install cocoapods
Configuration
Project Settings
Most configuration is done within Xcode (.xcodeproj or .xcworkspace).
- Info.plist: Used to define app metadata and request permissions (Camera, Location, etc.).
- Build Settings: Configure compiler flags, search paths, and target versions.
- Deployment Target: The minimum iOS version supported (similar to
minSdkin Android).
Multi-SDK and Environment Support
- Base SDK: The version of the iOS SDK used to build the app (latest stable).
- Deployment Target: Defines the minimum OS version required to run the app.
- Docker Integration: iOS builds cannot be run in standard Linux Docker containers because they require macOS and Xcode. Use macOS-based runners (GitHub Actions macOS runners, Mac minis, or specialized services like Codemagic) for CI/CD.
CLI Usage
Building
- List Targets/Schemes:
xcodebuild -list - Build for Simulator:
xcodebuild -scheme YourApp -project YourApp.xcodeproj -sdk iphonesimulator -configuration Debug - Clean Build:
xcodebuild clean -project YourApp.xcodeproj -scheme YourApp
Testing Execution
- Unit and UI Tests:
xcodebuild test -project YourApp.xcodeproj -scheme YourApp -destination 'platform=iOS Simulator,name=iPhone 15'
Cryptography and Secure Storage
- Keychain Services: Use the system Keychain to store small bits of sensitive data (passwords, keys).
- Secure Enclave: For hardware-backed cryptographic operations and biometric authentication (FaceID/TouchID).
- CryptoKit: Apple’s modern framework for cryptographic operations.
CI/CD Integration
iOS CI/CD requires macOS environments and typically uses Fastlane for automation.
Runner Requirements
- macOS Runners: GitHub Actions must use
macos-latest(or specific versions likemacos-13). Be aware of the higher cost and limited concurrency of macOS runners. - Xcode Version: Ensure the runner has the correct Xcode version installed and selected using
xcode-selectorxcversion.
GitHub Actions Example
Using ruby/setup-ruby with bundler-cache is the recommended way to manage Fastlane and its dependencies.
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Build and Sign
run: bundle exec fastlane build_and_sign
env:
MATCH_PASSWORD: $
APP_STORE_CONNECT_API_KEY_ID: $
APP_STORE_CONNECT_API_KEY_ISSUER_ID: $
APP_STORE_CONNECT_API_KEY_CONTENT: $
Signing and Provisioning
For CI, use Fastlane match to manage certificates and provisioning profiles. It ensures all developers and CI runners use the same identities.
- Match Read-only: Always use
match(type: "appstore", readonly: true)in CI to prevent the runner from creating new certificates. - App Store Connect API Key: Use API keys instead of Apple ID 2FA for smoother CI integration.
Xcode Selection
Pin Xcode to a specific version to avoid unexpected toolchain changes:
- name: Select Xcode
run: sudo xcode-select -s "/Applications/Xcode_15.3.app/Contents/Developer"
Caching
Cache CocoaPods, Swift Package Manager (SPM), and DerivedData to reduce build times:
- name: Cache CocoaPods
uses: actions/cache@v4
with:
path: Pods
key: $-pods-$
restore-keys: |
$-pods-
- name: Cache SPM
uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/.swiftpm
key: $-spm-$
restore-keys: |
$-spm-
- name: Cache DerivedData
uses: actions/cache@v4
with:
path: ~/Library/Developer/Xcode/DerivedData
key: $-deriveddata-$
restore-keys: |
$-deriveddata-
App Store Connect API Key and Match Access
- Store the App Store Connect API key as secrets:
ASC_KEY_ID,ASC_ISSUER_ID, andASC_KEY_CONTENT(base64 of the p8 file or the raw JSON when using fastlaneapp_store_connect_api_key). - Ensure the CI has read access to the Match repository (SSH deploy key or PAT) and use
readonly: truein CI.
Release Notes and Metadata
Managing release notes for the App Store is handled through App Store Connect.
Automated Release Notes (Fastlane)
If using Fastlane Deliver, release notes are managed in the
fastlane/metadata directory:
fastlane/metadata/en-US/release_notes.txt
Each language has its own folder. The file release_notes.txt contains the “What’s New in This Version” text.
Manual Release Notes
In App Store Connect:
- Select your app.
- Go to TestFlight > Test Information (for beta notes).
- Go to App Store > Version > What’s New in This Version (for production notes).
Signing and App Store Process
iOS apps must be signed by Apple-issued certificates.
- Certificates: Managed in the Apple Developer Portal (Development vs. Distribution).
- Provisioning Profiles: Links your App ID, Certificates, and Devices.
- Fastlane: Recommended for automating the signing and submission process.
fastlane match # Manage certificates fastlane release # Build and upload to TestFlight
Usage, tips and tricks
- SwiftUI: Preferred modern UI framework.
- Combine: Reactive framework for handling asynchronous events.
- Memory Management: Use ARC (Automatic Reference Counting). Watch for retain cycles (use
[weak self]).
Coding tips and tricks
- Instruments: Use the Instruments tool in Xcode for profiling performance and finding memory leaks.
- CocoaPods vs. SPM: Prefer Swift Package Manager (SPM) for modern dependencies.