Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type

Hi! I have that bug in the title, so can you please help me? I don’t know how to fix it, but I’m trying to follow a video to create a Log-in page. Here is my code, thanks.

import SwiftUI

struct ContentView: View {
var body: some View {

    Home()
}

}

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

struct Home : View {

var body: some View {
    
    VStack {
        
       SignUp()
        
    }
}

}

struct Login : View {

@State var color = Color.black.opacity(1.0)
@State var email = ""
@State var pass = ""
@State var visible = false

var body: some View {
    ZStack(alignment: .topTrailing){
        
        GeometryReader{_ in
            
            VStack {
                
                Image("logo")
                Text("Log into your account")
                    .font(.title)
                    .fontWeight(.bold)
                    .foregroundColor(self.color)
                    .padding(.top, 35)
                
                TextField("Email", text: self.$email)
                .padding()
                    .background(RoundedRectangle(cornerRadius: 4).stroke(self.email != "" ? Color (.black) : self.color, lineWidth: 2))
                    .padding(.top, 35)
               
                HStack(spacing: 15){
                    
                    VStack{
                    if self.visible{
                                       
                    TextField("Password", text: self.$pass)
                                  
                    }
                    else{
                                       
                SecureField("Password", text: self.$pass)
                                       
                    }
                        
                    }
                    Button(action: {
                        
                        self.visible.toggle()
                    }) {
                        
                        Image(systemName: self.visible ? "eye.slash.fill" : "eye.fill")
                            .foregroundColor(self.color)
                    }
                }
                .padding()
                .background(RoundedRectangle(cornerRadius: 4).stroke(self.pass != "" ? Color (.black) : self.color, lineWidth: 2))
                .padding(.top, 25)
                          
                HStack{
                    Spacer()
                    Button(action: {
                        
                    }) {
                        Text("Forgot password?")
                            .fontWeight(.bold)
                            .foregroundColor(Color(.black))
                            .padding()
                           
                            
                    }
                }
                .padding(.top, 25)
               
                Button(action: {
                    
                }) {
                    
                    Text("Log in")
                        .foregroundColor(.black)
                        .padding(.vertical)
                        .frame(width: UIScreen.main.bounds.width - 50)
                        .background(Color.white)
                        .padding(10)
                        .border(Color.purple, width: 5)
                    
                }
             .background(Color("Color"))
                         .cornerRadius(10)
                         .padding(.top, 25)
            }
            .padding(.horizontal, 25)

            
            
            
        }
        
        Button(action: {
            
        }) {
            
            Text("Register")
                .fontWeight(.semibold)
                .foregroundColor(Color(.black))
            
        }
    .padding()
        
        }
     
    }
}

struct SignUp : View {

@State var color = Color.black.opacity(1.0)
@State var email = “”
@State var pass = “”
@State var repass = “”
@State var visible = false
@State var revisible = false

var body: some View {

ZStack(alignment: .topLeading){
    
    GeometryReader{_ in
        
        VStack {
            
            Image("logo")
            Text("Log into your account")
                .font(.title)
                .fontWeight(.bold)
                .foregroundColor(self.color)
                .padding(.top, 35)
            
            TextField("Email", text: self.$email)
            .padding()
                .background(RoundedRectangle(cornerRadius: 4).stroke(self.email != "" ? Color (.black) : self.color, lineWidth: 2))
                .padding(.top, 25)
           
            HStack(spacing: 15){
                
                VStack{
                if self.visible{
                                   
                TextField("Password", text: self.$pass)
                              
                }
                else{
                                   
            SecureField("Password", text: self.$pass)
                                   
                }
                    
                }
                Button(action: {
                    
                    self.visible.toggle()
                }) {
                    
                    Image(systemName: self.visible ? "eye.slash.fill" : "eye.fill")
                        .foregroundColor(self.color)
                }
            }
            .padding()
            .background(RoundedRectangle(cornerRadius: 4).stroke(self.pass != "" ? Color (.black) : self.color, lineWidth: 2))
            .padding(.top, 25)
                      
            HStack(spacing: 15){
                
                VStack{
                if self.revisible{
                                   
                TextField("Password", text: self.$repass)
                              
                }
                else{
                                   
            SecureField("Password", text: self.$repass)
                                   
                }
                    
                }
                Button(action: {
                    
                    self.revisible.toggle()
                }) {
                    
                    Image(systemName: self.revisible ? "eye.slash.fill" : "eye.fill")
                        .foregroundColor(self.color)
                }
            }
            .padding()
            .background(RoundedRectangle(cornerRadius: 4).stroke(self.pass != "" ? Color (.black) : self.color, lineWidth: 2))
            .padding(.top, 25)

                Button(action: {
                    
                }) {
                    Text("Register")
                        .fontWeight(.bold)
                        .foregroundColor(Color(.black))
                        .padding()

                }
            }
            .padding(.top, 25)
           
            Button(action: {
                
            }) {
                
                Text("Log in")
                    .foregroundColor(.black)
                    .padding(.vertical)
                    .frame(width: UIScreen.main.bounds.width - 50)
                    .background(Color.white)
                    .padding(10)
                    .border(Color.purple, width: 5)
                
            }
         .background(Color("Color"))
                     .cornerRadius(10)
                     .padding(.top, 25)
        }
        .padding(.horizontal, 25)
    }
    
    Button(action: {
        
    }) {
        
      Image(systemName: "chevron.left")
        .font(.title)
            .foregroundColor(Color(.black))
        
    }
.padding()
    }
}

First: Please enclose your code in backticks ```—one on the line before and one on the line after. That will format your code nicely for the forums and will aid other posters in figuring out what is wrong. Also, code that is not enclosed in backticks gets strange things done to it by the forum software, such as “smartening” quotes, that cause Xcode to pitch a fit.

Now, on to your issue: That particular error you are getting usually means you have some non-SwiftUI code within a SwiftUI ViewBuilder, like this:

struct TestView: View {
    var body: some View {
        let message = "Hello world!"
        Text(message)
    }
}

You would have to change TestView to this in order to get it to compile:

struct TestView: View {
    var body: some View {
        let message = "Hello world!"
        return Text(message)
    }
}

OR it can mean that you have two Views within the body without wrapping them in some kind of container. Like, you can’t do this:

struct TestView: View {
    var body: some View {
        Text("Hello")
        Text("Goodbye")
    }
}

Instead, you have to do this:

struct TestView: View {
    var body: some View {
        Group {
            Text("Hello")
            Text("Goodbye")
        }
    }
}

Or use VStack, HStack, ZStack, whatever.

With that in mind…

In your SignUp view, you have this:

struct SignUp : View {
    
    @State var color = Color.black.opacity(1.0)
    @State var email = ""
    @State var pass = ""
    @State var repass = ""
    @State var visible = false
    @State var revisible = false
    
    var body: some View {
        
        ZStack(alignment: .topLeading){
            // code removed for brevity
        }
        
        Button(action: {
            print("done")
        }) {
            
            Image(systemName: "chevron.left")
                .font(.title)
                .foregroundColor(Color(.black))
            
        }
        .padding()
    }
}

That is, a ZStack and a Button not enclosed in some kind of container. Either include the Button within the ZStack or put them both inside a Group or something and your error will go away.

NOTE: This applies to Xcode 11. In Xcode 12, your code has no errors.