NEW: Learn to build the incredible iOS 15 Weather app today! >>

SOLVED: Xcode doesn't let me code...

Forums > 100 Days of SwiftUI

Hi guys,

when I'm trying to do the 1st challenge project->converter -> our first several lines are: Import Swift UI, -> Struct ContentView:View{

But my Xcode is showing the red warning "Type 'ContentView' does not conform to protocol 'View'", and doesn't show the iphone preview for me on the right side of the screen. Is anyone know what happened to it? When I did the project 1 "WeSplit", it worked fine.

Thanks a lot! you all have a good day!

Leona

   

You need import SwiftUI, not import Swift UI

import SwiftUI

struct ContentView: View {
    var body: some View {
        Text("Hello World")
    }
}

   

Patrick is right that you need import SwiftUI.

Also the View protocol (EG the View after ContentView:) requires a var body: some View { } which also require you to have a View eg Text("Hello World") in it. See Patrick example

If you can not see the preview then you need to check that this is after the ContentView struct

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

If it is then click on Editor>Canvas then it should show after you click resume.

   

thank you guys.

   

Hacking with Swift is sponsored by Sentry

SPONSORED With Sentry’s error and performance monitoring for iOS, you see mobile vitals that actually matter, can solve any latency issues quickly, and learn how each release is performing over time.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.