Thus, programs must be written for people to read, and only incidentally for machines to execute.
Harold Abelson, "Structure and Interpretation of Computer Programs" ( S.I.C.P )

Pitaya is a Swift HTTP / HTTPS networking library for people. Inspired by Alamofire and JustHTTP.

Example

Simple

Pita.build(HTTPMethod: .GET, url: "https://httpbin.org/get?hello=Hello%20Pitaya!")
    .responseJSON { (json, response) -> Void in
        print(json["args"]["hello"].stringValue) // get "Hello Pitaya!"
}

All examples

All Examples

Documentation

Read the documentation

Features

  • [x] Support Swift Package Manager
  • [x] Elegant APIs for people
  • [x] Support HTTP Basic Authorization
  • [x] Support setting SSL pinning
  • [x] Support setting HTTP raw body (include JSON body)
  • [x] Asynchronous & Queue
  • [x] Upload files fast
  • [x] Internal fully JSON support with JSONNeverDie
  • [x] Support setting custom HTTP headers
  • [x] almost 100% tested

Requirements

  • iOS 7.0+
  • Xcode 10.2 (Swift 5) (v4.x) in the default swift5 branch.
  • Xcode 9 (Swift 4) (v3.x) in swift4 branch.
  • Xcode 8 (Swift 3) (v2.x) in swift3 branch.
  • Xcode 7 (Swift 2) (v1.x) in master branch.
  • Xcode 6.4 (Swift 1.2) before v0.2.3

Installation

Swift Package Manager

You can use The Swift Package Manager to install Pitaya by adding the proper description to your Package.swift file:

import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    targets: [],
    dependencies: [
        .Package(url: "https://github.com/johnlui/Pitaya.git", versions: "1.3.4" ..< Version.max)
    ]
)

Note that the Swift Package Manager is still in early design and development, for more infomation checkout it's GitHub Page

Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

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

github "JohnLui/Pitaya"

Then fetch and build Pitaya:

carthage update

At last, add it to "Embedded Binaries" in the general panel use the "Add Other..." button. The Pitaya.framework binary file is lying in ./Carthage/Build/iOS directory.

Manually

git submodule add https://github.com/johnlui/Pitaya.git
open .

then drag Pitaya.xcodeproj into your Project, that's it!

If you want to run your project on devices with Pitaya, just go to PROJECT->TARGETS->[your project name]->General->Embedded Binaries, click +, select Pitaya.frameWork and click "Add".

Source File

Clone all files in the Source directory into your project.

Contribution

You are welcome to fork and submit pull requests.

License

Pitaya is open-sourced software licensed under the MIT license.

GitHub

https://github.com/johnlui/Pitaya