Fix Build Errors
Systematically diagnose and fix iOS build errors.
Workflow
1. Get Fresh Build Output
# Clean build to get all errors
xcodebuild clean build \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=iPhone 15' \
2>&1 | tee build_output.txt
2. Analyze Errors
Parse the build output for:
- Compilation errors (error:)
- Linker errors (ld:)
- Swift errors (Swift Compiler Error)
- Missing dependencies
3. Categorize Issues
Syntax Errors
- Missing brackets, semicolons
- Typos in code
- Invalid Swift syntax
Type Errors
- Type mismatch
- Missing protocol conformance
- Generic constraint violations
Import Errors
- Missing imports
- Circular dependencies
- Module not found
Concurrency Errors
- Sendable violations
- Actor isolation issues
- Data race warnings
Linker Errors
- Duplicate symbols
- Missing libraries
- Architecture mismatches
4. Fix Strategy
Think deeply about each error:
- What is the root cause?
- What is the minimal fix?
- Are there related errors that will resolve together?
5. Implement Fixes
Fix one category at a time:
- Fix import/module errors first
- Fix type errors
- Fix syntax errors
- Fix concurrency errors
- Rebuild after each category
6. Verify Fix
xcodebuild build \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=iPhone 15'
Common Fixes
Missing Sendable Conformance
// Add @unchecked Sendable for legacy types
extension LegacyType: @unchecked Sendable {}
// Or make type properly Sendable
struct MyType: Sendable {
let value: String // All properties must be Sendable
}
Actor Isolation
// Add MainActor annotation
@MainActor
final class ViewModel { }
// Or use nonisolated for non-UI methods
nonisolated func computeValue() -> Int { }
Generic Constraints
// Add missing protocol conformance
struct Item: Identifiable, Hashable {
let id: UUID
}