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

Post not yet marked as solved Up vote post of Antonio-Reyna Down vote post of Antonio-Reyna
1.8k views
  • 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

Answers

[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

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.