Xcode 16 iOS Build Failures: ModuleCache and DerivedData Solutions
Problem Statement
After updating to Xcode 16, iOS 18, and macOS 15, developers encounter persistent build failures when compiling Flutter applications (or native iOS projects). These manifest as ModuleCache and DerivedData-related errors:
Error (Xcode): no such file or directory:
'/Users/.../ModuleCache.noindex/Session.modulevalidation'
Error (Xcode): unable to rename temporary ... to output file:
'No such file or directory'
Error (Xcode): could not build module 'UIKit'
Error (Xcode): could not build module 'Flutter'
Commonly observed symptoms:
- Failure to build modules despite cleaning caches
- Missing SDKStatCaches and ModuleCache files
- Bridging header compilation failures
- Inconsistent errors that change between build attempts
WARNING
Standard troubleshooting steps like cleaning builds, deleting DerivedData, or reinstalling simulators do not resolve this issue.
Effective Solutions
Based on verified community solutions, here are the most reliable fixes:
1. Change DerivedData Location (Top Recommendation)
Why this works
Corrupted permissions or missing folders in the default DerivedData path cause these errors. Forcing Xcode to use a new location regenerates artifacts correctly.
Method 1: Workspace-relative Location (Per Project)
- Open your project in Xcode 16
- Navigate to File → Workspace Settings
- Change Derived Data to Workspace-relative location
Method 2: Custom Location (Global Fix)
- Access Xcode → Settings → Locations
- Under Derived Data, select Custom Path...
- Create a new empty folder (e.g.,
~/Documents/XcodeDerivedData
) - Select this folder as the new location
- Clean build folder (Cmd+Shift+K)
2. Reset DerivedData Permissions
If paths can't be changed:
sudo chown -R $USER ~/Library/Developer/Xcode/DerivedData
This command grants your user account full ownership of the DerivedData directory.
3. Manual Folder Recreation (Fallback Solution)
For specific "folder not found" errors:
- Open Terminal
- Create critical missing folders:
mkdir -p ~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex
mkdir -p ~/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex
Flutter-Specific Troubleshooting
If issues persist in Flutter projects:
flutter clean
flutter pub get
flutterfire configure # For FlutterFire projects
dart fix --apply
Additional Fixes
Reinstall iOS Simulator Runtimes
- Remove problematic runtimes:
- Xcode → Settings → Components → iOS Simulators → Click "–"
- Download latest runtime
- Install via Terminal:
xcrun simctl runtime add /path/to/runtime.dmg
Preventative Measures
- Regular Maintenance:bash
# Monthly cache cleanup rm -rf ~/Library/Developer/Xcode/DerivedData/*
- Backup Workspace Settings - Export configuration after successful builds
- Monitor Xcode release notes for ModuleCache fixes
WARNING
Avoid manually editing DerivedData contents during active development. Let Xcode manage these files automatically.
Confirmed Working Versions
These solutions succeed under:
- Xcode 16.0+ (build 24A320)
- iOS Simulators 18.0+ (22A5321d)
- Flutter 3.24.0+
- macOS 15.1 (Sonoma)
If issues persist after trying these solutions, report them via Apple Feedback Assistant as potential Xcode regressions.