Skip to content

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:

text
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:

  1. Failure to build modules despite cleaning caches
  2. Missing SDKStatCaches and ModuleCache files
  3. Bridging header compilation failures
  4. 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)

  1. Open your project in Xcode 16
  2. Navigate to File → Workspace Settings
  3. Change Derived Data to Workspace-relative location

Method 2: Custom Location (Global Fix)

  1. Access Xcode → Settings → Locations
  2. Under Derived Data, select Custom Path...
  3. Create a new empty folder (e.g., ~/Documents/XcodeDerivedData)
  4. Select this folder as the new location
  5. Clean build folder (Cmd+Shift+K)

2. Reset DerivedData Permissions

If paths can't be changed:

bash
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:

  1. Open Terminal
  2. Create critical missing folders:
bash
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:

bash
flutter clean
flutter pub get
flutterfire configure  # For FlutterFire projects
dart fix --apply

Additional Fixes

Reinstall iOS Simulator Runtimes

  1. Remove problematic runtimes:
    • Xcode → Settings → Components → iOS Simulators → Click "–"
  2. Download latest runtime
  3. Install via Terminal:
bash
xcrun simctl runtime add /path/to/runtime.dmg

Preventative Measures

  1. Regular Maintenance:
    bash
    # Monthly cache cleanup
    rm -rf ~/Library/Developer/Xcode/DerivedData/*
  2. Backup Workspace Settings - Export configuration after successful builds
  3. 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.