Kingfisher uses a dual build system approach supporting both Swift Package Manager and Fastlane/CocoaPods for maximum flexibility and distribution options.
Package.swift) - Modern dependency management and buildingfastlane/Fastfile) - Automated testing, building, and release workflowsKingfisher.podspec) - Legacy distribution and integration.github/workflows/) - Continuous integration and testing.
├── Package.swift # Swift Package Manager configuration
├── Kingfisher.podspec # CocoaPods specification
├── Gemfile # Ruby dependencies for Fastlane/CocoaPods
├── fastlane/
│ ├── Fastfile # Fastlane automation workflows
│ └── actions/ # Custom Fastlane actions
└── .github/workflows/
├── build.yaml # CI build workflow
└── test.yaml # CI test workflow
# Build for default platform
swift build
# Build with specific Swift version
swift build -Xswiftc -swift-version -Xswiftc 5
# Build for release
swift build -c release
# Build and run tests
swift test
# Generate Xcode project (if needed)
swift package generate-xcodeproj
First, install dependencies:
# Install Ruby dependencies
bundle install
Common build commands:
# Run all platform tests (iOS, macOS, tvOS, watchOS)
bundle exec fastlane tests
# Build for CI with specific destination
DESTINATION="platform=iOS Simulator,name=iPhone 15,OS=17.5" bundle exec fastlane build_ci
# Test for CI with specific destination
DESTINATION="platform=macOS" bundle exec fastlane test_ci
# Build specific platform
bundle exec fastlane build destination:"platform=iOS Simulator,name=iPhone 15"
# Lint both CocoaPods and SPM
bundle exec fastlane lint
The release workflow automates versioning, tagging, and distribution:
# Full release (tests, lint, version bump, GitHub release, CocoaPods push)
bundle exec fastlane release version:X.X.X
# Skip tests during release
bundle exec fastlane release version:X.X.X skip_tests:true
# Create XCFramework for distribution
bundle exec fastlane xcframework version:X.X.X
Release steps performed:
From Package.swift and Kingfisher.podspec:
From .github/workflows/test.yaml:
# macOS
bundle exec fastlane test destination:"platform=macOS"
# iOS Simulator
bundle exec fastlane test destination:"platform=iOS Simulator,name=iPhone 15,OS=17.5"
# tvOS Simulator
bundle exec fastlane test destination:"platform=tvOS Simulator,name=Apple TV,OS=17.5"
# watchOS Simulator (build only, no test)
bundle exec fastlane build destination:"platform=watchOS Simulator,name=Apple Watch Series 9 (41mm),OS=10.5"
From Package.swift:
Kingfisher (single library product)Kingfisher (sources in Sources/ directory)Available lanes in fastlane/Fastfile:
| Lane | Description | Parameters |
|---|---|---|
tests |
Run tests on all platforms | None |
test |
Run tests on specific platform | destination |
build |
Build for specific platform | destination |
test_ci |
CI test lane (builds watchOS) | Uses ENV["DESTINATION"] |
build_ci |
CI build lane | Uses ENV["DESTINATION"] |
lint |
Lint CocoaPods spec and SPM | None |
release |
Full release workflow | version, skip_tests (optional) |
xcframework |
Build XCFramework | version, swift_version, xcode_version |
| Variable | Description | Used By |
|---|---|---|
DESTINATION |
Build/test destination | CI workflows |
XCODE_VERSION |
Xcode version to use | CI workflows, Fastlane |
GITHUB_TOKEN |
GitHub API token | Release workflow |
Located in fastlane/actions/:
extract_current_change_log.rb - Extract changelog for versiongit_commit_all.rb - Commit all changessync_build_number_to_git.rb - Sync build number with gitupdate_change_log.rb - Update changelog fileBundle install fails
# Update bundler
gem install bundler
# Install with specific bundler version
bundle _2.x.x_ install
Xcode version mismatch
# Set Xcode version explicitly
XCODE_VERSION=16.2 bundle exec fastlane tests
# Or use xcode-select
sudo xcode-select -s /Applications/Xcode_16.2.app
Simulator not found
# List available simulators
xcrun simctl list devices
# Update destination string accordingly
CocoaPods push fails
# Verify pod spec locally first
pod lib lint Kingfisher.podspec
# Register session if needed
pod trunk register email@example.com
Swift version issues
# Override Swift version in build
bundle exec fastlane build xcargs:"SWIFT_VERSION=5.9"
Key build settings used:
BUILD_LIBRARY_FOR_DISTRIBUTION: YES (for XCFramework)SKIP_INSTALL: NO (for archiving)SWIFT_VERSION: 5.0 (default, can be overridden)Release builds generate:
Kingfisher-{version}.xcframework.zip - All platforms XCFrameworkKingfisher-iOS-{version}.xcframework.zip - iOS-only XCFrameworkBoth are code-signed with Apple Distribution certificate and uploaded to GitHub releases.