SwiftUI Previews that work in Xcode 15.2 now fail in Xcode 15.3 with failedToGenerateThunkInfo error

I have a Swift Package Manager module with some SwiftUI files that I was using Previews without issues in Xcode 15.2. When I upgraded to Xcode 15.3, it fails with “Cannot preview in this file. Unexpected error occurred”. When I click to get more info, this is the error:

== PREVIEW UPDATE ERROR:

    HumanReadableSwiftError
    
    BuildError: failedToGenerateThunkInfo(could not generate preview info: noTargetBuildGraph)

Is anyone experiencing the same problems? My preview, which lives in a SPM package, works totally fine in Xcode 15.2, but fails in Xcode 15.3. Any ideas for how to fix it? I've tried deleting DerivedData, resetting package caches, clean building. So frustrating seeing these regression issues popping up still.

I filed FB13678356 but it was quickly marked as "Investigation Complete - Unable to diagnose with current information" but there was no request for what further information I could provide! I attached a full sysdiagnose and error log!

Would also note, that when I revert back to Xcode 15.2, the previews go back to working...

  • Thanks for the reference to the feedback. I will investigate what is going on with the bug report.

Add a Comment

Replies

To add a bit more information that could hopefully help: I also tried creating a brand new swift package in my project with no dependencies to my other packages and I encountered the same error. I updated my FB with full diagnostic report as well so that hopefully will illuminate the error.

And again:

  • Deleted DerivedData folder
  • Reset Package Caches
  • Clean
  • Build

No luck unfortunately! Any insight would be much appreciated.

Ugh, so sorry you're encountering this. We got the diagnostic and are looking through it now. Unfortunately there's a lower level error below our component that is getting swallowed up and we're not sure why you're seeing this. We can't reproduce the issue with our own test projects. Are you able to reduce the project down enough to a small reproduction case? Could you attach it to the feedback so we can try to reproduce?

Updated the Feedback with a small example and was able to find a fix! It looks like the error is happening because of a library I use that uses macros. I eventually found a warning in the project logs and had to accept the above message after which it started working again.

Would note, not having enabled that macros plugin caused every preview in every package to stop working without any clear error message as to why! So glad I was able to get things working again though. Shoutout the guys at http://pointfree.co for taking a look!

Aha! And thank you for the info. We'll use this to ensure a better error messages comes out.

Any reason why you think the issue happens even if the dependency is unused or in a completely different package? For example, when I added a completely fresh swift package to my project that has no dependency on any other package in my system, the error still happened and previews in the new package fail as well.

Not sure. This sounds like the presence of the macro puts a block on the entire build pipeline until the macro is enabled.

Weird that it only causes a problem in previews though, no? It's surprising that I would be able to build the app on the device at all if that was the case. Do previews do the build that differently?