0

I've been successful using SwiftUI for a few months with very little Xcode experience. I'm trying to add some simple help screens that I would like to preview in the SwiftUI canvas. However, I'm receiving the following error:

OptimizationLevelError: not building -Onone

The message is shown when pressing the "diagnostics" button. Problem persists after pressing "try again" button.

Xcode: Version 11.3 (11C29)
Catalina: 10.15.2 (19C57)

The code could not be simpler:

import SwiftUI

struct HelpSortView: View {
    var body: some View {
        VStack {
            Text("You can sort the list by Name, Sail Number, Class, or Favorites.")
                .lineLimit(10)
            VStack(alignment: .center) {
                Image("help-sort")
            }
        }
    }
}

struct HelpSortView_Previews: PreviewProvider {
    static var previews: some View {
        HelpSortView()
    }
}

1 Answer 1

6

It turns out that I had my Xcode scheme, Build Configuration set to Release instead of debug. In Xcode, select Product, Scheme, Edit Scheme, Run (on left side), Info tab, Build Configuration, set drop-down to Debug.

Sign up to request clarification or add additional context in comments.

1 Comment

this whole IDE is a shit-show. Why cant the message just say - Use DEBUG build configuration to see a Preview!?.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.