alamofire

Alamofire compiled with older version of Swift language (2.0) than previous files (3.0) for architecture x86_64

穿精又带淫゛_ 提交于 2019-11-30 08:37:40
问题 When I move my program to the XCode8, I got this error: Alamofire compiled with older version of Swift language (2.0) than previous files (3.0) for architecture x86_64. I have update Alamofire to version 4.0, and set the Use Legacy Swift Language Version to NO. What's the matter? 回答1: Update your cocoa pods and clear your derive data folder and try to run again. In xcode 8 derived data folder changed, Go to File -> Workspace setting -> then see this image, Click on -> on path and clear that

Alamofire No Such Module (CocoaPods)

喜你入骨 提交于 2019-11-30 08:02:52
Using Xcode 7 I am trying to install Alamofire in a sample project. Have used the instructions from Ray Wenderlich's page Only change from above link is the podfile -- which is from GitHub page here because the version has been updated. I have also used the Swift 2.0 branch. Below is the snapshop of the error, my pod file and my terminal post installing the pod PODFILE TERMINAL P.S: I want to use cocoapods to install Alamofire. I don't want to download it from github page Try this one. For Swift 2.0 there is no need to add Alamofire.xcodeproj into your xcode. Simply copy and paste source

Failed to load Info.plist from bundle

…衆ロ難τιáo~ 提交于 2019-11-30 07:49:17
Cannot run app. Failed to load Info.plist from bundle error occurs. When I CMD+K clean the project, it runs fine. But I have to clean the project every time I make changes and run the app. Following is the screenshot of my podfile: I had tried all suggestion and none of them work Then I tried to Reset content and Setting of simulator and it worked for me. :) Simply Just quit the simulator and open it again and it should works fine Vinay Krishna Gupta 1: Remove app from simulator, 2: Product > Clean , 3: Simulator > Hardware > Reboot , It solved my problem. In case it doesn't resolved, change

Why does Unexpected non-void return value in void function happen? [duplicate]

落爺英雄遲暮 提交于 2019-11-30 07:48:01
问题 This question already has answers here : How to return value from Alamofire (5 answers) Closed 2 years ago . I created a function to get URL from API, and return URL string as the result. However, Xcode gives me this error message: Unexpected non-void return value in void function Does anyone know why this happens? func getURL(name: String) -> String { let headers: HTTPHeaders = [ "Cookie": cookie "Accept": "application/json" ] let url = "https://api.google.com/" + name Alamofire.request(url,

How to set Cookies in alamofire?

北城以北 提交于 2019-11-30 07:30:43
How to set Cookies in Alamofire such that such that every time I kill the app and restart it, the same cookie is sent? Swift 3.0 let cookies = HTTPCookie.cookies(withResponseHeaderFields: response.allHeaderFields , for: response.URL!) Alamofire.Manager.sharedInstance.session.configuration.HTTPCookieStorage?.setCookies(cookies, forURL: URL, mainDocumentURL: nil) Alamofire instance is shared singleton, so for all Request the cookie is set. Hope it's works for you. Krunal Get cookies from response using the NSHTTPCookie [cookiesWithResponseHeaderFields(_:forURL:)] method. // setCookies func

How to pass access token to Alamofire?

旧时模样 提交于 2019-11-30 07:06:23
I am trying to pass access token in Alamofire but getting confuse in various methods around web. Below are methods which we need to use. let todosEndpoint: String = "https:url......." let headers = [ "Authorization": "Bearer \(token!)", "Content-Type": "application/X-Access-Token" ] let Auth_header = [ "Authorization" : tokenString! ] Alamofire.request(todosEndpoint, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: Auth_header) .responseJSON { response in print("response.request \(response.request)") // original URL request print("response.response \(response.response)")

How to Connect localhost (with invalid certificate) using Alamofire?

泪湿孤枕 提交于 2019-11-30 06:44:27
This my first project using swift. I am usin alamofire to connect the API. I have a local copy form the API I want to use for debugging - so I can set test data - because the remote API has already real data that I can't mess with. The problem is I am getting the below error when I try to access https://localhost:8443/MyProject Optional(Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “localhost” which could put your confidential information at risk." UserInfo=0x7fbeb8c61ff0

Basic Authentication with Alamofire

拥有回忆 提交于 2019-11-30 06:38:32
Experiencing an issue when authenticating with Basic Auth. I am using a standard enum that conforms to URLRequestConvertible protocol to construct my requests. The issue is that when I manually set the authorization headers in the enum like so: let user = *** let password = *** let credentialData = "\(user):\(password)".dataUsingEncoding(NSUTF8StringEncoding)! let base64Credentials = credentialData.base64EncodedStringWithOptions([]) mutableURLRequest.setValue("Basic \(base64Credentials)", forHTTPHeaderField: "Authorization") I always get a 401 unauthorized response. However if I set the

Download File Using Alamofire 4.0 (Swift 3)

Deadly 提交于 2019-11-30 06:34:12
In older version of Alamofire. This is how I download file let destinationPath = Alamofire.Request.suggestedDownloadDestination( directory: .documentDirectory, domain: .userDomainMask); Alamofire.download(.GET, urlString, destination: destinationPath) .progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in // print(totalBytesRead) } .response { request, response, _, error in let downloadedFilePath = destinationPath(URL(string: "")!, response!); NSUserDefaultsHelper.saveURL(downloadedFilePath, key: urlString); completion(downloadedFilePath, true); } But now in the new version, my

Alamofire Xcode 8 Swift 3 results in 786 compile errors

心不动则不痛 提交于 2019-11-30 05:43:12
I am using the Xcode 8.0 GM. I created a default single-view app with my deployment target set to 9.0. In my Podfile I'm targeting the bleeding edge Swift 3 branch: source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.0' use_frameworks! target 'MyProject' do pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'swift3' end I run pod install and get ... Installing Alamofire (4.0.0-beta.2) ... fantastic, no problems. I open MyProject.xcworkspace . This pops up: I can't hit later because it tells me: Xcode 8 will not be able to build the target “Alamofire