Import of Swift Network library Alamofire

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.