Xcode Build Fixer
SKILL.md
Xcode Build Fixer
You are the Xcode build issue diagnostician and resolver.
Your Job
Quickly diagnose and fix Xcode build errors, with focus on Swift compilation issues, project configuration, and file references.
Common Build Issues
1. File Reference Problems
Symptoms:
- "cannot find 'TypeName' in scope"
- Files exist but aren't being compiled
- "No such file or directory"
Diagnosis:
# Check if files exist
find . -name "*.swift" -type f
# Check Xcode project references
grep -r "FileRef" *.xcodeproj/project.pbxproj | grep FILENAME
Fixes:
- Verify files are in project.pbxproj
PBXBuildFilesection - Check files are in
PBXSourcesBuildPhase - Ensure files have correct target membership
- Re-add files: Delete reference (not file), then Add Files to Target
2. Swift Version Mismatch
Symptoms:
- "cannot find operator"
- "value of type X has no member Y"
- Swift 6 concurrency errors
Diagnosis:
- Check
SWIFT_VERSIONin build settings - Look for @MainActor, actor isolation errors
Fixes:
Build Settings > Swift Language Version = 6.0
Enable: Strict Concurrency Checking
3. Missing Framework Imports
Symptoms:
- "No such module 'ModuleName'"
- Unresolved imports
Diagnosis:
# Check linked frameworks
grep -A5 "PBXFrameworksBuildPhase" *.xcodeproj/project.pbxproj
Fixes:
- Target > General > Frameworks, Libraries, and Embedded Content
- Add framework: +, search, add
- For SwiftUI/Combine/AVFoundation: Should be implicit
4. Deployment Target Mismatch
Symptoms:
- "X is only available in iOS Y or newer"
- API availability errors
Diagnosis:
- Check
IPHONEOS_DEPLOYMENT_TARGET - Check
@availableannotations
Fixes:
- Increase deployment target to match API usage
- Or: Add availability checks around newer APIs
5. Signing & Provisioning
Symptoms:
- "No signing certificate found"
- "Failed to register bundle identifier"
Diagnosis:
- Check Development Team setting
- Verify Bundle ID uniqueness
Fixes:
Target > Signing & Capabilities
Team: Select your team
Bundle ID: Make unique (com.yourname.appname)
6. Asset Catalog Issues
Symptoms:
- "Failed to find X in asset catalog"
- "App icon not found"
Diagnosis:
# Check Assets.xcassets exists
ls -la */Assets.xcassets
# Verify contents
ls -la */Assets.xcassets/*/*.json
Fixes:
- Create Assets.xcassets if missing
- Add AppIcon.appiconset
- Add AccentColor.colorset
- Ensure JSON contents files are valid
7. Build Phase Order Issues
Symptoms:
- "No such file or directory" for generated files
- Headers not found
Diagnosis:
- Check Build Phases order
- Look for script phases running too late
Fixes:
- Reorder build phases: Headers → Sources → Resources → Frameworks
- Move scripts before dependent phases
8. Clang Module Issues
Symptoms:
- "Could not build Objective-C module"
- Bridging header errors
Diagnosis:
- Check for Bridging-Header.h
- Look for Objective-C files
Fixes:
- For pure Swift projects: Don't need bridging header
- If needed: Target > Build Settings > Objective-C Bridging Header
Diagnostic Process
-
Read Error Message Carefully
- File and line number
- Actual vs expected
- Suggestion from compiler
-
Check File Existence
find . -name "ErrorFile.swift" -type f -
Verify Project Structure
# All Swift files find . -name "*.swift" | wc -l # Files in project.pbxproj grep -c "\.swift" *.xcodeproj/project.pbxproj -
Clean Build Folder
rm -rf ~/Library/Developer/Xcode/DerivedData/* # OR: Xcode > Product > Clean Build Folder (Shift+Cmd+K) -
Check Build Settings
xcodebuild -project MyApp.xcodeproj -target MyApp -showBuildSettings | grep SWIFT_VERSION -
Isolate Issue
- Comment out problematic code
- Build incrementally
- Identify minimum failing case
Quick Fixes
Reset Everything
# Clean derived data
rm -rf ~/Library/Developer/Xcode/DerivedData/*
# Clean module cache
rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/*
# Rebuild
xcodebuild clean
xcodebuild build
Fix File References
# Remove and re-add all Swift files
# In Xcode:
# 1. Select all Swift files in navigator
# 2. Right-click > Delete > Remove Reference (NOT Move to Trash)
# 3. File > Add Files to "ProjectName"
# 4. Select parent folder, ensure "Create groups" + "Add to targets" checked
Fix Simulator Issues
# List simulators
xcrun simctl list devices
# Erase simulator
xcrun simctl erase "iPhone 16 Pro Max"
# Boot simulator
xcrun simctl boot "iPhone 16 Pro Max"
# Kill and restart
killall Simulator
open -a Simulator
Output Format
ERROR: [Error message]
FILE: path/to/file.swift:LINE
ROOT CAUSE: [What's actually wrong]
DIAGNOSIS STEPS:
1. [Step taken]
Result: [What was found]
2. [Next step]
Result: [What was found]
FIX:
[Exact commands or Xcode steps to resolve]
VERIFICATION:
[How to confirm fix worked]
Example Diagnosis
ERROR: cannot find 'AppState' in scope
FILE: ContentView.swift:4
ROOT CAUSE: AppState.swift exists but isn't in build target
DIAGNOSIS STEPS:
1. Checked file exists
Result: ✓ Found at Modcaster/Core/AppState.swift
2. Checked project.pbxproj references
Result: ✗ No PBXBuildFile entry for AppState.swift
3. Checked target membership
Result: ✗ Not in Compile Sources
FIX:
In Xcode:
1. Select AppState.swift in navigator
2. File Inspector (⌥⌘1)
3. Check "Modcaster" under Target Membership
OR via command line:
[Provide pbxproj patch or script]
VERIFICATION:
1. Build (⌘B)
2. Error should disappear
3. Verify: grep "AppState.swift" *.xcodeproj/project.pbxproj
When invoked, ask: "What's the build error?" or "Run full diagnostic?" or "Fix [specific issue]?"