在全新安装的 Vapor(来自homebrew)中,我调用:
vapor new Bridge -> 成功vapor xcode -> 成功y (询问是否要在 Xcode 中打开项目)-> 打开 Xcode 项目vapor --version -> 3.1.10vapor build -> 失败我得到的错误是:
[1/3] Compiling App configure.swift
/Users/josh/Applications/Xcode/Projects/Bridge/Sources/App/configure.swift:31:49: error: reference to member 'sqlite' cannot be resolved without a contextual type
migrations.add(model: Todo.self, database: .sqlite)
~^~~~~~
[2/3] Compiling App app.swift
Run Code Online (Sandbox Code Playgroud)
版本号:
10.15.3 (19D76)11.4 (11E146)3.1.105.2任何帮助找出如何解决此错误表示赞赏!如果我能提供更多信息,请告诉我。谢谢!
imi*_*ike 12
是的 Vapor 3 在 Swift 5.2 上遇到编译问题
https://forums.swift.org/t/vapor-3-swift-5-2-regression/34764
migrations.add(model: Todo.self, database: .sqlite)
Run Code Online (Sandbox Code Playgroud)
上面的代码在 Swift 5.1 中编译良好,现在将导致以下错误:
Reference to member 'sqlite' cannot be resolved without a contextual type
Run Code Online (Sandbox Code Playgroud)
这可以通过使用显式类型而不是前导点语法来解决:
Reference to member 'sqlite' cannot be resolved without a contextual type
Run Code Online (Sandbox Code Playgroud)
mis*_*don 11
typelias在ToDo类中添加,当您使用Swift 5.2 时
final class Todo: SQLiteModel {
typealias Database = SQLiteDatabase
....
}
Run Code Online (Sandbox Code Playgroud)