Xcode 15 beta 7 Previews building issue

Summary

When trying to display SwiftUI previews, building the previews may fail with the following error:

Linking failed: linker command failed with exit code 1 (use -v to see invocation)
    
    ld: warning: search path '/Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator' not found
    ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found

Note that may app does not use CoreAudioTypes.

Observation

This issue seems to occur when two conditions are met:

  1. The SwiftUI view must be located in a Swift Package
  2. Somewhere in either the View or the #Preview a type from another package has to be used.

Say I have to packages one named Model-package and one named UI-Package. The UI-Package depends on the Model-Package. If I have a SwiftUI view in the UI-Package that uses a type of the Model-Package either in the View itself or in the #Preview, then the described error occurs. If I have a View in the UI-package that does not use a type of the Model-Package anywhere in its View or #Preview then the SwiftUI Preview builds and renders successful.

I created a bug report: FB13033812

I had same issue, but when trying to run tests. In my case the error was lying in my Package.swift file. I forgot to import a library for a target there and Xcode didn't show me corresponding error, when I fixed that, this error went away.

In my case, this was an issue with the latest version of Sentry (https://github.com/getsentry/sentry-cocoa/issues/3809).

I am having similar issues. Xcode 15.2 (15C500b)

I have the same issue with the view using ACarousel in Xcode version 15.3 (15E204a). Sorry Apple, I can't install Xcode 16 right now, I need everything to work predictable.

The preview stopped to work suddenly and nothing of the above fixes work.

Also, for some reason preview started to fail if XCTest fails to build.

Guys, actually, I found an unexpected workaround! If you can isolate the view, that potentially crashes, try to extract it in a separate View file. Make a custom subview that uses the 3d party lib, that causing the crash. In my case it was ACarousel. Then, in the view that you actually need to preview, use this subview. If the 3d party lib isn't imported there, the preview will work. Fantastic! This cost me 6 hours of work.

For me the error on CoreAudioType was a bogus one i was trying to add a library.a file and Xcode 15 uses by default the new linker. so adding -ld_classic to Other linker flags solved everything. Just putting it out there if anyone have the same issues.

Xcode 15 beta 7 Previews building issue
 
 
Q