Generic parameter 'V' could not be inferred Xcode error Please help

import SwiftUI
//MARK: Intergrating Apple Sign in
import AuthenticationServices
import GoogleSignIn
import GoogleSignInSwift
import Firebase

struct Login: View {
    @StateObject var LoginModel: LoginViewModel = .init()
    
    var body: some View {
        ZStack{
            
            Image("iOS-16-wallpaper")
                .resizable().aspectRatio(contentMode: .fill)
                .frame(width: UIScreen.main.bounds.width)
                .overlay(Color.black.opacity(0.35))
                .ignoresSafeArea()
            
            
            ScrollView(.vertical, showsIndicators: false) {
                VStack (alignment: .leading, spacing: 15) {
                    Image(systemName: "triangle")
                        .font(.system(size: 38))
                        .foregroundColor(.indigo)
                    
                    (Text("Welkom,")
                        .foregroundColor(.black) +
                     Text("\nLogin to continue")
                        .foregroundColor(.gray))
                    .font(.title)
                    .fontWeight(.semibold)
                    .lineSpacing(10)
                    .padding(.top,20)
                    .padding(.trailing,15)
                    
                    // MARK: Custom TextField
                    CustomTextField(hint: "+31 6 98675643", text: $LoginModel.mobileNo)
                        .disabled(LoginModel.showOTPField)
                        .opacity(LoginModel.showOTPField ? 0.4 : 1)
                        .overlay(alignment: .trailing, content: {
                            Button("Change"){
                                withAnimation(.easeInOut){
                                    LoginModel.showOTPField = false
                                    LoginModel.otpCode = ""
                                    LoginModel.CLIENT_CODE = ""
                                }
                            }
                            .font(.caption)
                            .foregroundColor(.indigo)
                            .opacity(LoginModel.showOTPField ? 1 : 0)
                            .padding(.trailing,15)
                        })
                        .padding(.top,50)
                    
                    CustomTextField(hint: "OTP Code", text: $LoginModel.otpCode)
                        .disabled(!LoginModel.showOTPField)
                        .opacity(!LoginModel.showOTPField ? 0.4 : 1)
                        .padding(.top,20)
                    
                    Button(action: LoginModel.showOTPField ? LoginModel.verifyOTPCode
                           : LoginModel.getOTPCode){
                        HStack(spacing: 15){
                            Text(LoginModel.showOTPField ? "Verify Code" : "Get Code")
                                .fontWeight(.semibold)
                                .contentTransition(.identity)
                            
                            Image(systemName: "line.diagonal.arrow")
                                .font(.title3)
                                .rotationEffect(.init(degrees: 50))
                        }
                        .foregroundColor(.black)
                        .padding(.horizontal,25)
                        .padding(.vertical)
                        .background {
                            RoundedRectangle(cornerRadius: 10, style: .continuous)
                                .fill(.black.opacity(0.05))
                        }
                    }
                           .padding(.top,30)
                    Text("(OR)")
                        .foregroundColor(.gray)
                        .frame(maxWidth: .infinity)
                        .padding(.top,30)
                        .padding(.bottom,20)
                        .padding(.leading,-60)
                        .padding(.horizontal)
                    
                        .overlay{
                            
                            HStack(spacing: 8){
                                //MARK: Custom Apple Sign in Button
                                CustomButton()
                                    .overlay{
                                        SignInWithAppleButton { (request) in
                                            LoginModel.nonce = $LoginModel.randomNonceString()
                                            request.requestedScopes = [.email,.fullName]
                                            request.nonce = $LoginModel.sha256(LoginModel.nonce)
                                            
                                            
                                        } onCompletion: {(result) in
                                            switch result{
                                            case .success(let user):
                                                print("Success")
                                                guard let credential = user.credential as?
                                                        ASAuthorizationAppleIDCredential else{
                                                    print("error with firebase")
                                                    return
                                                }
                                                LoginModel.appleAuthenticate(credential: credential)
                                            case.failure(let error):
                                                print(error.localizedDescription)
                                            }
                                        }
                                        .frame(height: 55)
                                        .clipShape(Capsule())
                                        
                                    }
                                
                                    .clipped()
                                
                                //MARK: Custom Google Sign in Button
                                CustomButton(isGoogle: true)
                                    .overlay{
                                        //MARK: We Have Native Sign in Button
                                        if let clientID = FirebaseApp.app()?.options.clientID{
                                            GoogleSignInButton{
                                                GIDSignIn.sharedInstance.signIn(with: .init(clientID: clientID), presenting: UIApplication.shared.rootController()){user,error in
                                                    if let error = error{
                                                        print(error.localizedDescription)
                                                        return
                                                    }
                                                    //MARK: Logging Google Users into Firebase
                                                    if let user{
                                                        LoginModel.logGoogleUsers(user: user)
                                                    }
                                                }
                                            }
                                            .blendMode(.overlay)
                                        }
                                    }
                                
                                    .clipped()
                                
                            }
                            .padding(.leading,-60)
                            .frame(maxWidth: .infinity)
                        }
                        .padding(.leading,60)
                        .padding(.vertical,15)
                    
                    
                }
                .alert(LoginModel.errorMessage, isPresented: $LoginModel.showError) {
                }
            }
        }
        .overlay
        @ViewBuilder
        func CustomButton(isGoogle: Bool = false) -> some View{
            HStack{
                Group{
                    if isGoogle{
                        Image("Google-Logo-Transparent-Background.png")
                            .resizable()
                            .renderingMode(.template)
                    }else{
                        Image(systemName: "applelogo")
                            .resizable()
                    }
                    
                    
                }
                .aspectRatio(contentMode: .fit)
                .frame(width: 25, height: 25)
                .frame(height: 45)
                .foregroundColor(.white)
                
                Text("\(isGoogle ? "Google" : "Apple")Sign in")
                    .font(.callout)
                    .foregroundColor(.white)
                    .lineLimit(1)
            }
            .padding(.horizontal,15)
            .background{
                RoundedRectangle(cornerRadius: 10, style: .continuous)
            }
        }
        
        
        
        struct Login_Previews: PreviewProvider {
            static var previews: some View {
                ContentView()
            }
        }
    }
}

Could you tell on which line the error occurs ?

Did you get this resolved? I have the same error.

In every case I've seen, this is a spurious error message caused by some syntax error buried within the view code. It can happen, for example, when you rename a function or member but still have a reference to the old name in SwiftUI code.

In the code you posted, I'd suspect that some reference to something in LoginModel is wrong.

You should file feedback with Apple on this, because it has been going on for years and wasting developers' time.

I agree with @Stokestack that it is a problem with Xcode. The usual way I debug it is by progressively commenting out sections of my code and observing at which point the compiler error disappears (or changes). This will help you narrow down and find the real syntax issue you need to fix.

I've spent 3 or 4 days working on a issue that came down to this message 'V' could not be inferred.
The problem turned out to be the compiler couldn't take the time to tell me the Transaction model did NOT have a property 'quantity' (it was changed to 'shares'). I found this out when I started factoring out pieces of the View into components... in this case when I got to creating a TransactionRow View the simplified code could be compiled and the 'quantity' property got flagged as non existent.

Wow - such a bad compiler message. Had me thinking my Query properties were bad.

Lesson I hope to learn - when things go to crap... simplify!

Swift compiler is dumb for these cases, even 3 years later. Just temporarily change the Group or ForEach into eg. VStack, and you'll see the actual problem's error message.

I was moving a large section of a View to a new (child) View and previously i had to refer to an element as self.varname -- however, now this var name was in the parent view and it caused this "generic parameter 'V'" issue. As stated, the best way to get through this is comment out sections of your view. As you do this, you'll see that you'll get more detailed (and more appropriate) errors that will help you find the issue.

Generic parameter 'V' could not be inferred Xcode error Please help
 
 
Q