Search code examples
swiftmacosxcode7alamofire

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


I'm trying to figure out how to use Alamofire in a command line app.

I can't use frameworks, so I've added the Alamofire source code into the app (so no import statement) and I'm able to directly reference the request() and other methods.

Is there a cleaner way to encapsulate Alamofire or is this a limitation in Swift 2.X at the moment?


Solution

  • For those who gonna need it here is the solution. If you don't have the file xcodeproject please generate

    $ swift package generate-xcodeproj
    

    You may need to fix the Deployment Target

    xcode deployment target

    Now time to add the 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"]),
        ]
    )
    

    I hope I have helped anyone who has the same problem :)