Skip to content

Xinguang/AlamofireSwiftyJSON

Repository files navigation

AlamofireSwiftyJSON

Build Status Swift version Carthage compatible CocoaPods compatible SwiftLint codecov.io GitHub release


Easy way to use both Alamofire and SwiftyJSON

Requirements

  • iOS 10.0+ / macOS 10.12+ / tvOS 10.0+ / watchOS 3.0+
  • Xcode 10.1+
  • Swift 4.2+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1.0+ is required to build AlamofireSwiftyJSON.

To integrate AlamofireSwiftyJSON into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'AlamofireSwiftyJSON'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate AlamofireSwiftyJSON into your Xcode project using Carthage, specify it in your Cartfile:

github "Xinguang/AlamofireSwiftyJSON"

Run carthage update to build the framework and drag the built AlamofireSwiftyJSON.framework into your Xcode project.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but AlamofireSwiftyJSON does support its use on supported platforms.

Once you have your Swift package set up, adding AlamofireSwiftyJSON as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .Package(url: "https://github.com/Xinguang/AlamofireSwiftyJSON.git", majorVersion: 1)
]

Usage

let URL = "http://httpbin.org/get"
Alamofire.request(URL, method: .get, parameters: ["foo": "bar"]).responseSwiftyJSON { response in
  print("###Success: \(response.result.isSuccess)")
  //now response.result.value is SwiftyJSON.JSON type
  print("###Value: \(response.result.value?["args"].array)")
}