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 have the same problem

  • Creating a new Flutter project and trying to compile it (it failed so that reduces the chances of it being a Flutter issue)

What happens if you create a new project directly in Xcode from File > New Project, does that fail the same way?

— Ed Ford,  DTS Engineer

Yes, I get the same error: Command ClangStatCache failed with a nonzero exit code

I am having the same problem

I am encountering the same issue. I upgraded to Xcode 16.1 and iOS 18.1, but it made no difference, same error messages.

Previously, I asked:

What happens if you create a new project directly in Xcode from File > New Project, does that fail the same way?

@chiragbhansali said yes, and then some other folks chimed in too.

I'd like to see the complete build report created for this brand new project:

  1. Choose View > Navigators > Reports.
  2. Select the report associated with your app’s build in the navigator.
  3. Using the filter bar at the top of the build report, select the filter buttons for All and All Messages.
  4. Click Export in the filter bar to save the detailed build report.

You can then use the forums attachment feature (paperclip icon) to share it here.

— Ed Ford,  DTS Engineer

I was getting this on command line builds using xcodebuild. Specifying a different DerivedData folder fixed it.

Chirag's thread on Stack Overflow mentions this solution: https://stackoverflow.com/questions/79118572/xcode-16-and-ios-18-project-not-compiling

Hi, I have the same issue. yesterday when I launch my flutter app I have this error Could not build the precompiled application for the device. Error (Xcode): stat cache file '/Users/me/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphoneos18.2-22C146-d5b9239ec3bf5b3adbecdf21472871e3.sdkstatcache' not found

I have restart my computer, make flutter clean, delete xcode and install again but anyting work. I have also change the directory of DeriveData but it doesn't work.

I managed to solve the issue by going to: Xcode > Settings > Locations as below:

and sat the Derived Data location to Relative

Note: Adding a preceding dot is optional, I only added it to hide the folder and ignore it it the repo by adding this **/.DerivedData/ to the .gitignore file

16

I'd like to see the complete build report created for this brand new project:

Here is what you requested except it is a macOS instead of an iOS project, resulted in the same error as @chiragbhansali stated: "Command ClangStatCache failed with a nonzero exit code"

Here is the steps:

Then

After than I clicked the play button and faced the attached build error.

It is obvious that it is not a Flutter issue. I hope apple can point us to the root cause of this issue and an a way to fix it instead of finding workarounds.

Versions

  • macOS 15.3.1
  • Xcode 16.2

This is working for me Thank You! @BSaeid

I have the same problem

Getting the same issue for both a Flutter project and a completely new project in Xcode.

Currently the only solution I found that is working is that to add the missing modules in the Frameworks without embedding. I also attached the build report of all the issues only due to limited size for upload.

I also attached the build report for a new project that sometimes builds .

New Project Build Report without only one SPM:

Flutter Build Report:

 Error (Xcode): unable to rename temporary
'/Users/arata/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/2EWGOL
NE8KJJO/os_object-IUD105RKVWT-1ed7e21d.pcm.tmp' to output file
'/Users/arata/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/2EWGOL
NE8KJJO/os_object-IUD105RKVWT.pcm': 'No such file or directory'


Parse Issue (Xcode): Could not build module 'os_object'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
m/Developer/SDKs/iPhoneSimulator18.2.sdk/usr/include/dispatch/dispatch.h:62:
9


Parse Issue (Xcode): Could not build module 'Dispatch'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
m/Developer/SDKs/iPhoneSimulator18.2.sdk/System/Library/Frameworks/CoreFound
ation.framework/Headers/CFStream.h:19:9


Parse Issue (Xcode): Could not build module 'CoreFoundation'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
m/Developer/SDKs/iPhoneSimulator18.2.sdk/System/Library/Frameworks/Foundatio
n.framework/Headers/Foundation.h:5:9


Parse Issue (Xcode): Could not build module 'CoreFoundation'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
m/Developer/SDKs/iPhoneSimulator18.2.sdk/System/Library/Frameworks/Security.
framework/Headers/SecBase.h:27:9

...

Parse Issue (Xcode): Could not build module 'Dispatch'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
m/Developer/SDKs/iPhoneSimulator18.2.sdk/usr/include/xpc/xpc.h:6:9


Parse Issue (Xcode): Could not build module 'Foundation'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
m/Developer/SDKs/iPhoneSimulator18.2.sdk/System/Library/Frameworks/UIKit.fra
mework/Headers/UIKit.h:7:8


Parse Issue (Xcode): Could not build module 'CoreFoundation'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
m/Developer/SDKs/iPhoneSimulator18.2.sdk/System/Library/Frameworks/CoreGraph
ics.framework/Headers/CGBase.h:11:9


Parse Issue (Xcode): Could not build module 'CoreGraphics'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
m/Developer/SDKs/iPhoneSimulator18.2.sdk/System/Library/Frameworks/CoreImage
.framework/Headers/CoreImageDefines.h:16:9

...

Parse Issue (Xcode): Could not build module 'Foundation'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
m/Developer/SDKs/iPhoneSimulator18.2.sdk/System/Library/Frameworks/OpenGLES.
framework/Headers/EAGL.h:7:9

...


Parse Issue (Xcode): Could not build module 'UIKit'
/Users/arata/Developer/carp/flutter-plugins/packages/health/example/ios/Pods
/Target%20Support%20Files/permission_handler_apple/permission_handler_apple-
prefix.pch:1:8


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


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

I have the same problem

I have the same problem, I've tried all solutions above and none of them worked.

Xcode 16 and iOS 18 project not compiling
 
 
Q