我试图弄清楚如何在命令行应用程序中使用Alamofire。
我无法使用框架,因此我将Alamofire源代码添加到了应用程序中(因此没有import语句),并且能够直接引用request()和其他方法。
是否有一种更干净的方法来封装Alamofire,或者这目前在Swift 2.X中是一个限制吗?
对于那些需要它的人,这里是解决方案。如果您没有文件xcodeproject,请生成
$ swift package generate-xcodeproj
您可能需要修复部署目标
现在添加Alamofire的时间
import PackageDescription
let package = Package(
name: "SuiteTest",
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.0.0")),
.package(url: "https://github.com/JohnSundell/Files", from: "4.0.0")
],
targets: [
.target(
name: "SuiteTest",
dependencies: ["Files", "Alamofire"]),
.testTarget(
name: "ASuiteTestTests",
dependencies: ["Assure-SuiteTest"]),
]
)
我希望我能帮助会有同样问题的任何人:)