Xcode 16 and iOS 18 project not compiling

I updated Xcode and MacOS recently and haven't been able to compile my Flutter app on iOS devices/simulators since then. The error keeps changing every time I run it but here's one of the output in the terminal after running flutter run:

Uncategorized (Xcode): Command SwiftGeneratePch emitted errors but did not return a nonzero exit code to
indicate failure


Error (Xcode): no such file or directory:
'/Users/chiragbhansali/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation'


Error (Xcode): stat cache file
'/Users/chiragbhansali/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator18.0-22A3362-
db63dc9361471f152f572502bdbfe70a.sdkstatcache' not found


Error (Xcode): unable to rename temporary
'/Users/chiragbhansali/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/3F9VRK3CXAUUD/UIKit-1KHQ7M05IF
VXC-56601391.pcm.tmp' to output file
'/Users/chiragbhansali/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/3F9VRK3CXAUUD/UIKit-1KHQ7M05IF
VXC.pcm': 'No such file or directory'


Error (Xcode): could not build module 'UIKit'
/Users/chiragbhansali/Chirag/Coding/Projects/app/test/build/ios/Debug-iphonesimulator/Flutter.framewo
rk/Headers/FlutterAppDelegate.h:7:8


Error (Xcode): could not build module 'Flutter'
/Users/chiragbhansali/Chirag/Coding/Projects/app/test/ios/Runner/GeneratedPluginRegistrant.h:9:8


Error (Xcode): failed to emit precompiled header
'/Users/chiragbhansali/Library/Developer/Xcode/DerivedData/Runner-eifcguceazlwumgsyzegclqdrbqt/Build/Intermed
iates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_PB6A5GFLTNPC-clang_3F9VRK3CXAUUD.pch' for
bridging header
'/Users/chiragbhansali/Chirag/Coding/Projects/app/test/ios/Runner/Runner-Bridging-Header.h'


Uncategorized (Xcode): Command PrecompileSwiftBridgingHeader emitted errors but did not return a nonzero exit
code to indicate failure


Uncategorized (Xcode): Command SwiftEmitModule failed with a nonzero exit code


Uncategorized (Xcode): Command SwiftCompile failed with a nonzero exit code


Could not build the application for the simulator.
Error launching application on iPhone 16 Pro.

What I have tried so far:

  1. Deleting iOS SDK and simulators
  2. Cleaning Xcode build cache using cmd+shift+k
  3. Creating a new Flutter project and trying to compile it (it failed so that reduces the chances of it being a Flutter issue)
  4. Clearing the DerivedData folder
  5. Clearing settings and cache of simulators
  6. Restarting laptop

Versions:

    1. Xcode: 16.0
    1. iOS: 18.0
    1. MacOS: 15.1 (didn't work with 15.0 either)
    1. Flutter: 3.24

I resolved the issue by opening the project (the ./ios/Runner.xcworkspace) in Xcode and building it in Xcode once. After that flutter run worked, maybe it works for you too :)

Same issue for me on IOS, since macOS and Xcode latest updates. Also tried all solutions above and none of them worked.

Versions:

MacOs 15.3.2

Xcode 16.2 (16C5032a)

IOS SDK 18.2 (22C146)

IOS Simulator 18.3.1 (22D8075)

Grant Full Ownership to Your User fixed Xcode 16 compiling issues for me. Run this command in the terminal to change the ownership of the DerivedData folder to your user: sudo chown -R $USER ~/Library/Developer/Xcode/DerivedData

I have the same problem

This question in stackoverflow addresses the problem:

https://stackoverflow.com/questions/79118572/xcode-16-and-ios-18-project-not-compiling

Change the location of DerivedData folder in Xcode Workspace settings (File -> Workspace Settings) to something else.

I'm encountering an issue while trying to build my iOS app in Xcode for the simulator.

Issue:

  • Xcode Version: 15.x
  • macOS Version: 14.x (Sonoma)
  • Simulator: iPhone 16 Pro
  • Error Message: Command ClangStatCache failed with a nonzero exit code

Steps Taken:

  1. Cleaned build folder (Shift + Cmd + K)
  2. Deleted DerivedData (rm -rf ~/Library/Developer/Xcode/DerivedData)
  3. Updated Xcode and checked iOS SDK updates
  4. Disabled Clang Static Analyzer Cache

None of these steps resolved the issue. Any help would be appreciated!

Thanks in advance.

We had this problem in our app (not using Flutter) and it seems like it was caused by a prebuild script running simctl commands, which somehow deleted/prevented the creation of CLANG_MODULES_BUILD_SESSION_FILE and SDK_STAT_CACHE_PATH from the standard derived data directory.

Xcode 16 and iOS 18 project not compiling
 
 
Q