SwiftUI preview failing with failedToGenerateThunkInfo

I have an iOS app by using a swift package to hold most of the logic. However, the previews of SwiftUI views often fail with following error:
Code Block
HumanReadableSwiftError
BuildError: failedToGenerateThunkInfo(Error Domain=com.apple.xcbuild Code=19 "could not generate preview info: noTargetBuildGraph" UserInfo={NSLocalizedDescription=could not generate preview info: noTargetBuildGraph})


To reproduce this, please clone https://github.com/pointfreeco/isowords and check for preview of ChangelogView.
Answered by ForumsContributor in

Hi, did you come to solve this issue ?

+1 (having the exact same problem with the exact same app.)

Unfortunately this is a bug that must be fixed in XCode. Here are some more discussions regarding the same: https://github.com/pointfreeco/swift-composable-architecture/discussions/581 with some solutions that work for sometimes.

I have started having this same issue occur with my app in Xcode 15.3:

== 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. Filed: FB13678356

I have started having this same issue occur with my app in Xcode 15.3:

== 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. Filed: FB13678356

Same error and behavior. Fails on 15.3, loads on 15.2. Feedback: FB13722734.

thanks for the feedback IDs! I'll make sure they get to the right team asap. For issues with previews generally you'll want to include the following diagnostics:

Steps to generate helpful diagnostics:

  1. Download and install the logging profile on all devices involved. Instructions and profiles are available here: https://developer.apple.com/bug-reporting/profiles-and-logs/?name=swift
  2. Reproduce the issue
  3. Click the "Diagnostics" button in the error banner in Previews' Canvas area (or if the banner is missing you can use the menu: Editor > Canvas > Diagnostics)
  4. In the sheet that appears, click "Generate Report" in the bottom left of the sheet
  5. Attach (or make from the folder) the resulting zip file to the bug report (will be named something like previews-diagnostics-0123456789.zip)
  6. Generate the sysdiagnose(s) and attach those too

Same error for me in Xcode 15.3:

  • my SwiftUI view is in a SPM package module.
  • that module has no dependencies on anything else
  • It builds fine.
  • But SwiftUI previews fail with "BuildError: failedToGenerateThunkInfo(could not generate preview info: noTargetBuildGraph)"

after introducing a macros-dependent swift package into my project, swiftui previews started to fail with the same error and the following diagnostic description:

[targetMissingUserApproval] Target [MACRO NAME HERE] must be enabled before it can be used.)

i fixed this issue locally by

  1. heading to the issue navigator aka the exclamation mark in the triangle within xcode’s left sidebar,
  2. tapping on the “macro target [MACRO NAME HERE] must be enabled…” warning, and
  3. tapping trust & enable on the system alert that popped up.

after following these steps, i was once again able to build swiftui previews on xcode 15.4. i hope this fix works for others whose projects utilize (directly or indirectly) macros!

SwiftUI preview failing with failedToGenerateThunkInfo
 
 
Q