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
How to Pass Data to Another Controller on Dismiss Viewcontroller
Save Eventually on Pfobject with Pffile (Parse Local Datastore)
Strong Reference to a Weak References Inside Blocks
How to Move to the Next Page in Facebook JSON Response Using iOS Sdk
Swiftui Transitions: Scale from Some Frame - Like iOS Homescreen Is Doing When Opening an App
How to Delete a Child from Firebase (Swift)
How to Get Uitouch Location from Uigesturerecognizer
Unknown Class in Interface Builder
iOS Input Focused Inside Fixed Parent Stops Position Update of Fixed Elements
How to Disable User Interaction on Mkmapview
_Unused Flag Behavior/Usage (Gcc with Objective-C)
Easiest Way of Getting Reverse Geocoded Current Location from iOS
Playing Video into Uitableview
Uidatepicker Bug? Uicontroleventvaluechanged After Hitting Minimum Internal
Add a View on Top of the Keyboard Using Inputaccessoryview
Uisearchcontroller Not Redisplaying Navigation Bar on Rotate