我将.package(url: "https://github.com/vapor-community/postgresql-provider.git", .upToNextMajor(from: "2.1.0"))
添加到我的Package.swift文件中,运行vapor update
并让它重新生成Xcode项目。当我添加PostgreSQLProvider的导入时,Xcode无法找到它。我已经通过homebrew安装了postgresql和pkg-config。
我正在使用Xcode 9和Swift 4
答案 0 :(得分:2)
看起来您正在使用Swift 4软件包管理器。它的API已更新,因此您必须将依赖项显式添加到目标:
// swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "Project",
products: [
.library(name: "App", targets: ["App"]),
.executable(name: "Run", targets: ["Run"])
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "2.1.0")),
.package(url: "https://github.com/vapor/fluent-provider.git", .upToNextMajor(from: "1.2.0")),
.package(url: "https://github.com/vapor-community/postgresql-provider.git", .exact("2.1.0"))
],
targets: [
.target(name: "App", dependencies: ["Vapor", "FluentProvider", "PostgreSQLProvider"],
exclude: [
"Config",
"Public",
"Resources",
]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App", "Testing"])
]
)
见上文,我将PostgreSQLProvider
数据包添加到dependencies
目标的App
数组中。
答案 1 :(得分:0)
我也遇到了这个问题并且不足以使用蒸汽xcode,因为它只会重新生成项目并且不会像你刚刚添加的postgree那样获取新的依赖项,以解决这个问题。后来蒸汽xcode,项目关闭的两个命令