Module 'Alamofire' Has No Member Named 'Request'

Module 'Alamofire' has no member named 'request'

Alamofire.xcodeproj -> Build Phases -> Complie Sources

If (0 item), then "[+] Alamofire.swift".

It's OK :)

Module 'Alamofire' has no member named 'upload'

When you check Uploading Data to a Server example, it uses AF instead of Alamofire:

AF.upload(multipartFormData: { multipartFormData in
multipartFormData.append(Data("one".utf8), withName: "one")
multipartFormData.append(Data("two".utf8), withName: "two")
}, to: "https://httpbin.org/post")
.responseJSON { response in
debugPrint(response)
}

Module 'Alamofire' has no member named 'SessionManager'

SessionManager class essentially renamed to just Session in Alamofire 5. So you can replace your implementation with this:

Alamofire.Session.default.session.getAllTasks { tasks in
tasks.forEach { $0.cancel() }
}

Update: As @JonShier mentioned in the comment, the correct way to cancel all requests is by calling Session's cancelAllRequests(completingOnQueue:completion:) function:

Alamofire.Session.default.cancelAllRequests()

Alamofire 5 showing error after installing it with Carthage, 'Alamofire has no member named request

You are using Alamofire 5 then you should use AF.request instead of Alamofire.request.

Error: Module Alamofire has no member named 'request'

I updated to XCode 8 with Swift 3.0 and Alamofire version 4.0. Everything working perfectly now

Alamofire 5 type 'Request' has no member 'authorizationHeader'

What used to be under Request.authorizationHeader(..) is now under HTTPHeaders.authorization(..), to better explain it I'll put here the code how it has changed:

Before this commit we had in Request.swift:

/// Returns a base64 encoded basic authentication credential as an authorization header tuple.
///
/// - parameter user: The user.
/// - parameter password: The password.
///
/// - returns: A tuple with Authorization header and credential value if encoding succeeds, `nil` otherwise.
open class func authorizationHeader(user: String, password: String) -> (key: String, value: String)? {
guard let data = "\(user):\(password)".data(using: .utf8) else { return nil }
let credential = data.base64EncodedString(options: [])
return (key: "Authorization", value: "Basic \(credential)")
}

Since this commit in Alamofire 5 we can find it within HTTPHeaders.swift:

/// Returns a `Basic` `Authorization` header using the `username` and `password` provided.
///
/// - Parameters:
/// - username: The username of the header.
/// - password: The password of the header.
///
/// - Returns: The header.
public static func authorization(username: String, password: String) -> HTTPHeader {
let credential = Data("\(username):\(password)".utf8).base64EncodedString()

return authorization("Basic \(credential)")
}

That means now you should be able to do the same by doing:

let headers: HTTPHeaders = [
.authorization(username: consumerKey!, password: consumerSecret!),
.accept("application/json")
]


Related Topics



Leave a reply



Submit