iosswiftauth0auth0-lock

Use of unresolved identifier 'connections'; did you mean 'Connections' in Auth0?


I'm working on Auth0 Lock integration, i'm getting error Use of unresolved identifier 'connections'; did you mean 'Connections'?.

.withConnections {_ in
  connections.database(name: "Username-Password-Authentication", requiresUsername: true)
}

I changed code to

Connections.database(name: "Username-Password-Authentication", requiresUsername: true) 

Now I'm getting error Instance member 'database' cannot be used on type 'Connections'

When I changed code to

Connections().database(name: "Username-Password-Authentication", requiresUsername: true)

Getting error 'Connections' cannot be constructed because it has no accessible initializers

I changed code to

$0.database(name: "Username-Password-Authentication", requiresUsername: true)

Getting Anonymous closure arguments cannot be used inside a closure that has explicit arguments

https://github.com/auth0/Lock.swift

https://auth0.com/docs/libraries/lock-ios/v2#configuration-options

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    Lock
        .classic()
        // withConnections, withOptions, withStyle, and so on
        .withOptions {
            $0.oidcConformant = true
            $0.scope = "openid profile"
        }
        .onAuth { credentials in
            // Let's save our credentials.accessToken value
        }
        .withConnections {_ in
            connections.database(name: "Username-Password-Authentication", requiresUsername: true)
        }
        .withStyle {
            $0.title = "Company LLC"
            $0.logo = LazyImage(name: "123.png")
            $0.primaryColor = UIColor(red: 0.6784, green: 0.5412, blue: 0.7333, alpha: 1.0)
        }
        .present(from: self)

Solution

  • It seems the Auth0 documentation is erroneous here. If you look at the Lock.swift source file you see that a ConnectionBuildable is passed as argument. You need to use this to build your connections.

    Try this:

    .withConnections { connections in
        connections.database(name: "Username-Password-Authentication", requiresUsername: true)
    }
    

    or the same thing using anonymous closure arguments:

    .withConnections {
        $0.database(name: "Username-Password-Authentication", requiresUsername: true)
    }