Having an issue running the preview for SwiftUI views inside my framework. Here is a project structure.
Preview for SwiftUI views that are in the main target ( ContentView, GradientView) work as expected.
However, when I’m trying to preview the view inside UI.xcodeproject ( SwiftUIView) I’m getting an error
PotentialCrashError: Update failed
XCPreviewAgent may have crashed. Check ~/Library/Logs/DiagnosticReports for any crash logs from your application.
==================================
| RemoteHumanReadableError
|
| LoadingError: failed to load library at path "/Users/yevgeniy/Library/Developer/Xcode/DerivedData/Hackathon-abjguuvpzyisdncwvpeguazdifiu/Build/Intermediates.noindex/Previews/Hackathon/Intermediates.noindex/UI.build/Debug-iphonesimulator/UI.build/Objects-normal/x86_64/SwiftUIView.1.preview-thunk.dylib": Optional(dlopen(/Users/yevgeniy/Library/Developer/Xcode/DerivedData/Hackathon-abjguuvpzyisdncwvpeguazdifiu/Build/Intermediates.noindex/Previews/Hackathon/Intermediates.noindex/UI.build/Debug-iphonesimulator/UI.build/Objects-normal/x86_64/SwiftUIView.1.preview-thunk.dylib, 0x0002): tried: '/Users/yevgeniy/Library/Developer/Xcode/DerivedData/Hackathon-abjguuvpzyisdncwvpeguazdifiu/Build/Intermediates.noindex/Previews/Hackathon/Products/Debug-iphonesimulator/SwiftUIView.1.preview-thunk.dylib' (errno=2), '/Applications/Xcode_14.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Users/yevgeniy/Library/Developer/Xcode/DerivedData/Hackathon-abjguuvpzyisdncwvpeguazdifiu/Build/Intermediates.noindex/Previews/Hackathon/Intermediates.noindex/UI.build/Debug-iphonesimulator/UI.build/Objects-normal/x86_64/SwiftUIView.1.preview-thunk.dylib' (errno=2), '/Users/yevgeniy/Library/Developer/Xcode/DerivedData/Hackathon-abjguuvpzyisdncwvpeguazdifiu/Build/Intermediates.noindex/Previews/Hackathon/Intermediates.noindex/UI.build/Debug-iphonesimulator/UI.build/Objects-normal/x86_64/SwiftUIView.1.preview-thunk.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')))
|
| ==================================
|
| | MessageSendFailure: Message send failure for <ServiceMessage 115: update>
~/Library/Logs/DiagnosticReports folder is empty.
Using Xcode 14.0 in Rosetta mode.
Xcode 14.1 in Rosetta mode - same issue
Ths same configuration without Rosetta works fine. (in my prod project I have to use Rosetta because of 3rd party dependency)
Build for Active architecture set to NO
Build for Active architecture set to YES
changes nothing
All the usual things tried:
- Rebuild project
- Clean Derived Data
- Etc.
The answer to those who came here with the same problem: If you have to run in **Rosetta** mode, keep checking this post. Otherwise, run without **Rosetta**, that will solve your problem.