Alamofire is very good networking library written in Swift. There are two ways to integrate Alamofire in project:
Cocoa Pod:
To Add new Alamofire
library to your current project go with the pod installation
. below is the code you have to integrate in your pod file for fresh installation of Alamofire.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 2.0'
With the latest release of Alamofire 2.0 request method get change.
I am posting some sample steps which will help you most
Here is my sample code,
//Step:
import Alamofire
// Step : 1
var manager = Manager.sharedInstance
// Specifying the Headers we need
manager.session.configuration.HTTPAdditionalHeaders = [
"Content-Type": "application/graphql",
"Accept": "application/json" //Optional
]
// Step : 3 then call the Alamofire request method.
Alamofire.request(.GET, url2).responseJSON { request, response,result in
print(result.value)
}
Try this or you can check the latest update from alamofire on xcode 7:
https://github.com/Alamofire/Alamofire
In previous version of Alamofire there is one more parameter for handle in request method, now that was removed. Check Git for more information. I think this will help you more.
- Mannual:
Download the Alamofire from git: https://github.com/Alamofire/Alamofire , then extract the downloaded folder.
From your project -> click on add files to "project"
-> navigate to extracted folder -> find Alamofire.xcodeproj
-> select the Alamofire.xcodeproj
file -> please make sure Copy items if needed
is checked.
Now its time to add Alamofire into embedded binaries. To do that click on project name and then navigate to General tab -> select Embedded Binaries
-> click on '+' -> now add Alamofire.xcodeproj
.
Lastly use import Alamofire
in .swift file, whenever you want to use Alamofire.
But my personal opinioin is, if you are using Xcode 7
and Swift 2
then you must go with the Cocoapod installation for Alamofire