我正在尝试将一个小型 swift 程序“ main.swift ”编译为 Ubuntu 18.08 上的可执行文件。我使用Swift 包管理器来管理我的依赖项。在这个非常简单的情况下,我只有一个依赖项,即这个开源 CryptoKit。我有一个 swift 文件,它只是尝试导入 CryptoKit。
import Foundation
import CryptoKit
print("phew")
我的Package.swift文件如下所示:
// swift-tools-version:5.2
import PackageDescription
let package = Package(
name: "decryp",
dependencies: [
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMajor(from: "1.0.1"))
],
targets: [
.target(
name: "decryp",
dependencies: ["swift-crypto"]
),
.testTarget(
name: "decrypTests",
dependencies: ["decryp"]),
]
)
当我尝试使用swift build构建可执行文件时,它会获取存储库,但随后会给出未找到产品的错误。快速构建的标准输出:
Fetching https://github.com/apple/swift-crypto.git
Cloning https://github.com/apple/swift-crypto.git
Resolving https://github.com/apple/swift-crypto.git at 1.0.2
'decryp' /home/kah/decryp: error: product 'swift-crypto' not found. It is required by target 'decryp'.
warning: dependency 'swift-crypto' is not used by any target
也许我错过了一些明显的东西?我仍然是 swift 世界的初学者。