Xcode 13 - warning: Could not read serialized diagnostics file: error("Invalid diagnostics signature")

I just updated to xcode 13 but when i try to compile im getting this error:

warning: Could not read serialized diagnostics file: error("Invalid diagnostics signature") 

And also i dont know if its part of the same but then it cant find some frameworks.

Cannot find type 'CLLocation' in scope

thanks

Can you find and show the minimized steps to reproduce the issue?

I also upgraded to Xcode 13 and have the same error

warning: Could not read serialized diagnostics file: error("Invalid diagnostics signature") (in target .... Command CompileSwift failed with a nonzero exit code

I deleted the DerivedData folder and also cleaned the build folder, it makes no difference. Every time I compile the app I get the same error.

I am looking in the DerivedData/.....build/Objects-normal/arm64/ folder

For classes that compiled successfully, 7 files were created with the same name and different extensions, as follows .d .dia .o .swiftdeps ~partial.swiftdoc ~partial.swiftmodule ~partial.swiftsourceinfo

However for the classes that did not compile only the following two files were created .d .dia Also the .dia file was a file of zero bytes So it appears to have fallen over when creating the .dia file

[Edit] I see that I made an answer, when it should have been a comment. Sorry about that. [/Edit]

@Antonio-Reyna @gbdslmad I'm having the same error. Was fine yesterday. Stealth update of xcode to xcode 13 this morning. I didn't even know, when to build and xcode crashed to desktop. When it loaded up again it was xcode 13.

Sigh. Auto updating dev tools isn't cool. I can see having to update if I wanted to support the new ios... But I don't.

I'm getting these build errors mostly around my watch app/extension.

In addition to  Could not read serialized diagnostics file: error("Invalid diagnostics signature") Another one I'm getting is Cannot find 'CKNotification' in scope. I think it's related, or at least because something can't build to completion. I haven't updated my m1 macair to the latest big sur update, so maybe that's it? So annoying.

One thing I noticed was that it was trying to build for iPhoneOS15.0.sdk

  cd /Users/aaron/Documents/Vision/Pods
  export DEVELOPER_DIR\=/Applications/Xcode.app/Contents/Developer
  export SDKROOT\=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.0.sdk


Command CompileSwiftSources failed with a nonzero exit code

I'm having the same errors (or at least very similar). I'm hoping that going back to xcode 12.5.1 https://download.developer.apple.com/Developer_Tools/Xcode_12.5.1/Xcode_12.5.1.xip

[Update] Downloading xcode 12.5.1 removed the errors and everything built fine. So I'll just stick with that until xcode 13 is better.

I also have the "Could not read serialized diagnostics file: error("Invalid diagnostics signature")" warning. I've tried a few improvements with restarting Project after deleting it's "xcuserdata". Thank you for posting this Question, hope it gets resolved as soon as possible. I WILL be back frequently on the status of the Question. It's on my Calendar. How many other Developers have the same situation?

Here are details of the solution that applied in my specific case.

I took a look at the output in the Report Navigator ⌘9 (right-most icon at the top of the Navigator pane, which is at the left edge of Xcode). I clicked on the most recent failed build shown in the list, and that produced a detailed list of modules and files that were compiled in the build.

I was able to narrow down the problem to a source file in third-party code which was using a symbol that is not yet available to me for my macOS target requiring macOS 11.3. The errant symbol (AttributedString) was found within a conditional compilation block similar to this:

#if compiler(>=5.5)
@available (iOS 15, macOS12, tvOS 15, watchOS 8, *)
extension AttributedString { ... }
#end if

Fortunately, the maintainers of the third-party code were quick to remedy the problem by further refining the conditional compilation as follows:

#if compiler(>=5.5) && !os(macOS) && !targetEnvironment(macCatalyst)
@available (iOS 15, macOS12, tvOS 15, watchOS 8, *)
extension AttributedString { ... }
#end if

So before the fix, I got the error that is the subject of this post:

warning: Could not read serialized diagnostics file: error("Invalid diagnostics signature")

Also before the fix, the accompanying type error was:

Cannot find type 'AttributedString' in scope

After the fix, these errors went away since the offending symbol was not compiled.

So there's a type (such as CLLocation in the original post) that isn't available in the current framework set, but it is being encountered somewhere in source code where maybe it should be conditionally not compiled at all.

In my case, the third-party code was being used via Swift Package Manager, so I had to right-click on the package in the Project Navigator ⌘1 and choose "Update Package".

This is in addition to my comment two days age. After doing a little more troubleshooting I found this information.

Hope this helps to isolate the root cause.

I'm having the same errors.  pod IQKeyboardManager in XCode 13 iOS 15.

Adding "import MapKit" fixed it for me.

This is how I solve

In my case, I had problem with BonMot package and I solved errors with following these steps.

1-I upgraded BonMot package with the latest version which was 6.0.0

2-The package requires minimum IPHONEOS_DEPLOYMENT_TARGET attribute to 11 and I changed it.

Changing attribute may affect your project, in that case you need to upgrade all packages to 11

If you have hundred packages in your pod file you can add these line your podFile than run pod update

$iOSVersion = '11.0'

post_install do |installer|
 # add these lines:
 installer.pods_project.build_configurations.each do |config|
  config.build_settings["EXCLUDED_ARCHS[sdk=*]"] = "armv7"
  config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
 end
  
 installer.pods_project.targets.each do |target|
   
  # add these lines:
  target.build_configurations.each do |config|
   if Gem::Version.new($iOSVersion) > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
   end
  end
   
 end
end

Thanx

I was having this error today and restarting Xcode did not fix it but closing out all the tabs within Xcode fixed the problem for me.

I was having this issue with 13.2 and 13.3 beta. I'm developing a SwiftUI package.

Any compiler error caused the problem, and the detailed compiler error can only be found in the stack trace for the Uncategorized error.

I can insert any compiler error to make this occur, then if I remove the error there is no issue as its only affecting error reporting. The file "PropertyEditorViewModel.swift" does not have any compilation errors, but the warning is that diagnostics cannot be read for it.

I fixed this by moving some of the code in PropertyEditorViewModel.swift to a different file. After doing this, I receive correct compilation errors.

I will not go into the details of the moved code apart from noting that it is not the main class in that file, but a class that implements a separate generic protocol referred to in the main class.

I take it that the compiler is struggling with the unrelated classes in the original source file and pulling them apart into separate files helps the compiler when it needs to process diagnostics. Simplification fixed the problem for me.

Xcode 13 - warning: Could not read serialized diagnostics file: error("Invalid diagnostics signature")
 
 
Q