I'm trying to run the Automatic Preview in Xcode 11, however even though the project builds successfully, the automatic preview fails giving me the error Failed to build ContentView.swift. Failed to code sign ContentView.swift.
I have just created the project without any modifications to the auto generated code. Even the code signing has also been set properly. Note I'm using the Free Apple Developer Account. Could this cause any problem?
Following is the code from ContentView.swift file:
import SwiftUI
struct ContentView : View {
var body: some View {
Text("Hello World")
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
First select the Xcode using following command
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Then run
sudo xcodebuild -license
Hope it is helpful
I solved that problem by going to the Xcode - Preferences -> Locations and assigning the Command Line Tools to Xcode 11. Also keep in mind that it is a beta, so it is unstable.
I had this problem as I was using // to comment beside my curly brackets to check I had them all in the right spot in my screen code. Xcode seems to cope with a few but once the screen gets too large and too many comments...... Now I comment on the line below and no problems!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With