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

Thanks for the bug report, we'll take a look. Just to clear up one thing: the warning about missing CoreAudioTypes is benign. The real failure is later with missing symbols. This might be a known issue or it might be a new instance of a previously fixed issue. Either way, we'll dig into it.

I found a workaround in an old thread (https://developer.apple.com/forums/thread/697772) that works for me: To successfully build a preview for a View in a Swift Package, switch to the scheme of the package the view is located in. Thanks to user @derekc00 for pointing it out.

I am facing the same issue, is this just isolated to XCode 15 betas. The same app and same code run fine in XCode14.2 and .3

I'm also facing a somewhat similar issue - at least as far as the error message is concerned.

https://feedbackassistant.apple.com/feedback/13208223

same for me in XCTest.

If I add Host Application, AND Allow testing Host Application APIs

tests build correctly.

any other combinations, fails.

you can try this,

go to Build Settings > Linking > Other Linker Flags and add -fprofile-instr-generate

Not sure if this related. My project doesn't need CoreAudioTypes frameworks but it complaints anyway. My project able to build for iOS but throw this similar error for tvOS.

It turns out that 2 of my swift files that are shared between iOS and tvOS, they're importing iOS specific lib. In my case, UIImpactFeedbackGenerator and UISelectionFeedbackGenerator. All I did was to guard the import and implementing with #if os(iOS) and the errors went away.

Seeing similar behavior on both Xcode 15.0.1 RC and Xcode 15.1 Beta. In our case, it's iOS SwiftUI Previews not working at all in SPM package (as opposed to for example an iOS app).

Same code works fine on Xcode 14.x versions.

Edit: Submitted case **** for this alongside diagnostics. Hope it helps, thanks for looking into it @Developer Tools Engineer!

Are you seeing this behavior with views located in your app or located in packages?

I haven’t had this issue since the later Xcode 15 betas. My solution (as described above) is to always switch to a scheme for the app or package the view is located in.

Same thing happend to me on Unity build to Xcode. Im using FirebaseAuth and GoogleSignIn. My project work fine in Xcode 14 but i cant built when update Xcode 15

FirebaseAuth: https://firebase.google.com/docs/auth/unity/google-signin

GoogleSignIn: https://github.com/googlesamples/google-signin-unity

Any update over this issue I added MessageKit in project and through bridging I am getting the error.

I'm having the same exact issue when building with Xcode 15.0.1:

ld: framework 'CoreAudioTypes' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm seeing the same 'CoreAudioTypes' build error when attempting to run UITests on Xcode 15.0.1

This issue still persists in Xcode 15.1 beta 3, this is really frustrating same code works using Xcode 14.3.1 and it's a shame that I can't update. Just to be clear to me this issue only happens when running unit tests compile the app works fine just the unit tests don't.

Out of the blue this error suddenly popped up on Xcode, release 15.0.1. The error message is bogus for sure. What helped was "Product>Clean Build Folder...", then a rebuild+launch to device!

Xcode 15 beta 7 Previews building issue
 
 
Q