使用未解析的标识符 'connections';您是说 Auth0 中的 'Connections' 吗?

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

我正在处理 Auth0 Lock 集成,我收到错误 使用未解析的标识符 'connections';你是说 'Connections' 吗?

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

我将代码更改为

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

现在我收到错误 实例成员 'database' 不能用于类型 'Connections'

当我将代码更改为

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

获取错误 'Connections' 无法构造,因为它没有可访问的初始值设定项

我将代码更改为

[=15=].database(name: "Username-Password-Authentication", requiresUsername: true)

获取匿名闭包参数不能在具有显式参数的闭包中使用

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 {
            [=16=].oidcConformant = true
            [=16=].scope = "openid profile"
        }
        .onAuth { credentials in
            // Let's save our credentials.accessToken value
        }
        .withConnections {_ in
            connections.database(name: "Username-Password-Authentication", requiresUsername: true)
        }
        .withStyle {
            [=16=].title = "Company LLC"
            [=16=].logo = LazyImage(name: "123.png")
            [=16=].primaryColor = UIColor(red: 0.6784, green: 0.5412, blue: 0.7333, alpha: 1.0)
        }
        .present(from: self)

这里的 Auth0 文档似乎有误。如果您查看 Lock.swift source file,您会看到 ConnectionBuildable 作为参数传递。您需要使用它来建立联系。

试试这个:

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

或使用匿名闭包参数做同样的事情:

.withConnections {
    [=11=].database(name: "Username-Password-Authentication", requiresUsername: true)
}

error 在 .withConnections 的 closure 中 您没有使用 _

命名参数

无参数

.withConnections { _ in }

带参数

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

您得到使用未解析的标识符'connections';您是说 'Connections' 吗? 因为 connections 未声明为闭包参数。

尝试:

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

或者如果你想使用匿名参数,不要声明任何参数:

.withConnections { 
  [=11=].database(name: "Username-Password-Authentication", requiresUsername: true)
}