Alamofire: Build error with Swift Package Manager
I’m using Xcode 8 and the official SPM. I try to use Alamofire through SPM:
import PackageDescription
let package = Package(
name: "swift-playground",
dependencies: [
.Package(url: "https://github.com/Alamofire/Alamofire.git", majorVersion: 4)
]
)
However, swift build
gives me a lot of errors:
Cloning https://github.com/Alamofire/Alamofire.git
HEAD is now at 5fe5b20 Added release notes to the CHANGELOG and bumped the version to 4.0.0.
Resolved version: 4.0.0
Compile Swift Module 'Alamofire' (17 sources)
/Users/skyline/Projects/Github/swift-playground/Packages/Alamofire-4.0.0/Source/DispatchQueue+Alamofire.swift:33:25: error: use of undeclared type 'TimeInterval'
func after(_ delay: TimeInterval, execute closure: @escaping () -> Void) {
^~~~~~~~~~~~
/Users/skyline/Projects/Github/swift-playground/Packages/Alamofire-4.0.0/Source/SessionDelegate.swift:111:50: error: 'URLSessionStreamTask' is only available on OS X 10.11 or newer
open var streamTaskReadClosed: ((URLSession, URLSessionStreamTask) -> Void)?
^
/Users/skyline/Projects/Github/swift-playground/Packages/Alamofire-4.0.0/Source/SessionDelegate.swift:111:50: note: add @available attribute to enclosing class
open var streamTaskReadClosed: ((URLSession, URLSessionStreamTask) -> Void)?
^
/Users/skyline/Projects/Github/swift-playground/Packages/Alamofire-4.0.0/Source/SessionDelegate.swift:114:51: error: 'URLSessionStreamTask' is only available on OS X 10.11 or newer
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 16 (4 by maintainers)
So I’ve spent some time on
swift-users
trying to get to the bottom of how this all is supposed to work and I think I have it pretty much figured out. Although there are still some serious shortcomings, you can at least get things to work. If you follow these steps, you can get things working.Using SPM with Alamofire
master
branch as4.0.2
Package.swift
file for your project similar to the following:main.swift
file inSources
Configuration.xcconfig
file to override the deployment targetMACOSX_DEPLOYMENT_TARGET
setting so the xcconfig value can be picked up by the projectHere’s an example of a small
SPMTester
project that I put together.Summary
Now this is certainly still WAY more painful than it should be, but at least it’s actually up and running. Once the community adds more features this process should get easier and easier.
From those errors it appears you aren’t using Xcode 8. Alamofire 4 requires Xcode 8. If you need to keep using Xcode 7, please use Alamofire 3.5.0.
@cnoon thx for the temporary solution. +1 for this issue.
@cnoon so there is no known solution that supports
swift build
from the command line without using Xcode?@jshier Please consider reopening this. I think maybe #1549 is also related to this.
I used Xcode8 too, got the same errors (https://cloud.githubusercontent.com/assets/8327777/18612992/2221341e-7da0-11e6-9f58-73a57e8451d0.png)
I’m indeed using Xcode 8 and Swift 3. I think there may be some kind of bug in SPM.