First, manual Import
1, official website download Alamofire
2. Unzip the downloaded file into the top-level directory of the project
3. Open Project Add Files
4, select Project TARGETS > General > Embedded Binaries > + (ADD) complete. Note Select the corresponding framework, we choose Frameworkios here
5, detect whether to add success, first detect the project deployment version, using Alamofire project Deployment target minimum of 8.0, and then run the following code, debug zone output content. At this point, add success
Alamofire.request (. GET, "Https://httpbin.org/get", Parameters: ["foo": "Bar"]) . Responsejson {response in print ( Response.request) //original URL request print (response.response)//URL response print (response.data) //Server data print (Response.result) //Result of response serialization if let JSON = Response.result . value { print ("JSON: \ (JSON)") }}
Second, Cocoapods Import
Cocoaspods is a dependency management tool for Cocoa Engineering, the installation Alamofire requires a cocoaspods minimum version of 0.39.0, the following command to view the pod version, the version is too low for the students need to upgrade first
Pod--version
1, enter the project directory, create the Podfile file, the file content is as follows
<your Target name> replaced by the name of the project
SOURCE ' Https://github.com/CocoaPods/Specs.git ' Platform:ios, ' 9.0 ' use_frameworks!target ' <your target name> ' Do pod ' alamofire ', ' ~> 3.4 ' end
2, then the terminal switches to the directory where the Podfile input command
Pod Install
The above two steps have already completed the import work, in need to use Alamofire Place direct import can
References (stamp here):
> https://github.com/Alamofire/Alamofire#installation
Import of Swift Network library Alamofire