在命令行中使用 Alamofire OS X app (Xcode 7) - 代码封装?

Using Alamofire in a command line OS X app (Xcode 7) - code encapsulation?

我正在尝试了解如何在命令行应用程序中使用 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"]),
    ]
)

希望我能帮助到遇到同样问题的人:)