Preview throwing error HumanReadableSwiftError ConfigurationError: noPreviewInfos

In my current project, previews barely work. Most of the time, the following error is displayed on top:

Cannot preview in this file -- Unexpected error occurred

Sometimes, refreshing works by clicking the Try Again button, but usually that takes multiple tries. When I click the Diagnostics button, the following error is shown:

Code Block
HumanReadableSwiftError
ConfigurationError: noPreviewInfos(arch: "x86_64", sdkRoot: "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.2.sdk")


This happens both in Xcode 12 and the beta Xcode 12.2. Who has a solution for this?

Accepted Reply

The problem cropped up again, and I bit the bullet. In Xcode, I created a new project and copied all the source from the old to the new project. I recreated everything in the new project, meaning: set the bundle ID, version number, build number, launch screen et cetera.

That fixed it. So, it's not the source files themselves, it's something in the project file(s). I did a manual diff between the <projectname>.xcodeproj/project.pbxproj of the old and the new project, but I gave up after staring 15 minutes at the incredibly messy diff. Preview now work.

Replies

Did you ever figure out a solution to this? SwiftUI previews have been tough to troubleshoot, and after some changes, this is the error I'm stuck on.
Once, I found that the project had multiple targets. And the file wasn't a member of the currently selected target. But that only happened once. Other times, I found that repeatedly clicking the preview button (or repeatedly pressing Option-Cmd-P) fixed it. But most of the time, the preview is simply not appearing.

Xcode 12.0 and 12.2 series are rough for me, right now.
After upgrading to Xcode 12.2 beta 3 (12B5035g), one failing preview offered an error: a unittest (i.e. an XCTestCase subclass) was not part of any target. Of course, it was part of the unittest target only. So I have no idea why the preview depended on that unittest file. I just deleted the file from Xcode, and for this project, the error "Failed to build ***.swift" keeps popping up above the preview but if I repeatedly hit Cmd-Shift-P, it does render.

Edit: never mind, other views no longer render. Very frustrating.
I'm having this issue in Xcode 12.3 (12C33). Any ideas what is causing this issue? if you keep hitting try again sometimes randomly works once and then keep failing
The problem cropped up again, and I bit the bullet. In Xcode, I created a new project and copied all the source from the old to the new project. I recreated everything in the new project, meaning: set the bundle ID, version number, build number, launch screen et cetera.

That fixed it. So, it's not the source files themselves, it's something in the project file(s). I did a manual diff between the <projectname>.xcodeproj/project.pbxproj of the old and the new project, but I gave up after staring 15 minutes at the incredibly messy diff. Preview now work.
I got the same problem. after I remove use_frameworks! :linkage => :static in my Podfile, the preview works again

This help me "Product" => "Clean build folder"

  • Works for me too.

Add a Comment

This error appeared when I ran preview whilst having an iOS 13 simulator selected. Switching to a simulator of iOS14+ resolved the issue for me.

In Xcode 15.3 I had the same error, and I solved it cleaning the Xcode storage

Settings > Storage > Developer

Clean the Xcode Project Build Files.