5

I've trying to add a SwiftUI view to an existing UIKit + Storyboards based tvOS project. The actual build works fine and I can run in the simulator & see my SwiftUI view, but when I resume the SwiftUI preview I get 'Failed to build MyClass.swift' with the following diagnostics:

SwiftUI preview build error

I saw this similar SO post regarding the -bundle and -bitcode_bundle cannot be used together error, but my configuration is already the way the answer suggests (setting the Mach-O type to Executable and ensuring no Bundle Loader is set).

There's also a warning about /Applications/Xcode.app/Contents/SharedFrameworks-appletvsimulator not being found. That directory certainly does not exist, but nowhere in my project is SharedFrameworks-appletvsimulator referenced that I can find. Also, if I create a new SwiftUI project it doesn't complain about that.

The SwiftUI code is literally just a new "Hello World" SwiftUI file from the Xcode template - I haven't modified it at all.

Does anyone have any ideas what's going on here or how to fix it?

Jordan
  • 4,133
  • 1
  • 27
  • 43

1 Answers1

2

For me the fix was disabling the code coverage option:

Go to your scheme menu -> select edit scheme -> go to the "Test" section on the left side menu -> uncheck the Code Coverage mark

  • I'm using Xcode 12.5
  • iOS minimum target 13.4

There are diffrent reasons for the preview to fails and several posts about it , for example: This Question

Boaz Frenkel
  • 618
  • 5
  • 15