Description
Another network wrapper for URLSession. Built to be cross platform, simple, small and easy to create tests at the network layer of your application.
Frisbee alternatives and similar libraries
Based on the "Network" category.
Alternatively, view Frisbee alternatives based on common mentions on social networks and blogs.
-
Perfect
Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and moreβ¦) -
Reachability.swift
Replacement for Apple's Reachability re-written in Swift with closures -
swifter
Tiny http server engine written in Swift programming language. -
SwiftSoup
SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS) -
Netfox
A lightweight, one line setup, iOS / OSX network debugging library! π¦ -
SwiftHTTP
Thin wrapper around NSURLSession in swift. Simplifies HTTP requests. -
APIKit
Type-safe networking abstraction layer that associates request type with response type. -
CocoaMQTT
MQTT 5.0 client library for iOS and macOS written in Swift -
Swifton
A Ruby on Rails inspired Web Framework for Swift that runs on Linux and OS X -
Zewo
Lightweight library for web server applications in Swift on macOS and Linux powered by coroutines. -
ResponseDetective
Sherlock Holmes of the networking layer. :male_detective: -
SwiftWebSocket
A high performance WebSocket client library for swift. -
BlueSocket
Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux. -
Connectivity
π Makes Internet connectivity detection more robust by detecting Wi-Fi networks without Internet access. -
WKZombie
WKZombie is a Swift framework for iOS/OSX to navigate within websites and collect data without the need of User Interface or API, also known as Headless browser. It can be used to run automated tests / snapshots and manipulate websites using Javascript. -
Pitaya
π A Swift HTTP / HTTPS networking library just incidentally execute on machines -
PeerKit
An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps -
Express
Swift Express is a simple, yet unopinionated web application server written in Swift -
Heimdallr.swift
Easy to use OAuth 2 library for iOS, written in Swift. -
Socks
π Non-blocking TCP socket layer, with event-driven server and client. -
Reach
A simple class to check for internet connection availability in Swift. -
Digger
Digger is a lightweight download framework that requires only one line of code to complete the file download task -
Embassy
Super lightweight async HTTP server library in pure Swift runs in iOS / MacOS / Linux -
SOAPEngine
This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and AppleTV app. -
SwiftyOAuth
A simple OAuth library for iOS with a built-in set of providers -
XcodeServerSDK
Access Xcode Server API with native Swift objects. -
BigBrother
Automatically sets the network activity indicator for any performed request.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Frisbee or a related project?
Popular Comparisons
README
Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application.
Install
Carthage
To integrate Frisbee into your Xcode project using Carthage, specify it in your Cartfile:
github "ronanrodrigo/Frisbee" ~> 0.2.5
Run carthage update to build the framework and drag the built Frisbee.framework into your Xcode project.
CocoaPods
To integrate Frisbee into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'Frisbee', '0.2.5'
end
Then, run the following command:
$ pod install
Swift Package Manager
To integrate Frisbee into your Swift Package Manager project, set the dependencies in your Package.swift
:
// swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "<Your Packege Name>",
dependencies: [
.package(url: "https://github.com/ronanrodrigo/Frisbee.git", from: "0.2.5")
],
targets: [
.target(name: "<Your Packege Name>", dependencies: ["Frisbee"])
]
)
Usage
GET Request
Decodable Entity
A Response
of a Request
made in Frisbee will return an enum of Result<T>
. Where T
must be a decodable entity. In this guide it will be used a Movie
entity like bellow.
struct Movie: Decodable {
let name: String
}
Making a Request
You could abstract Frisbee usage in some class and inject an object that conforms to Getable
protocol. So, in production ready code you will use an instance of NetworkGet
object.
class MoviesController {
private let getRequest: Getable
// Expect something that conforms to Getable
init(getRequest: Getable) {
self.getRequest = getRequest
}
func listMovies() {
getRequest.get(url: someUrl) { moviesResult: Result<[Movie]> in
switch moviesResult {
case let .success(movies): print(movies[0].name)
case let .fail(error): print(error)
}
}
}
}
// Who will call the MoviesController must inject a NetworkGet instance
MoviesController(getRequest: NetworkGet())
Query Parameters
It is easy to use query strings paramenters. Just create an Encodable
struct and use it in get(url:query:onComplete:)
method.
struct MovieQuery: Encodable {
let page: Int
}
let query = MovieQuery(page: 10)
NetworkGet().get(url: url, query: query) { (result: Result<Movie>) in
// ...
}
POST Request
Same way as GET request, Frisbee has a Postable
protocol. And in prodution ready code you will use an instance of NetworkPost
.
Making Request
It is the same logic as GET request.
class MoviesController {
private let postRequest: Postable
// Expect something that conforms to Postable
init(postRequest: Postable) {
self.postRequest = postRequest
}
func createMovie() {
postRequest.post(url: someUrl) { moviesResult: Result<[Movie]> in
switch moviesResult {
case let .success(movies): print(movies[0].name)
case let .fail(error): print(error)
}
}
}
}
Body Arguments
It is easy to use body paramenters. Just create an Encodable
struct and use it in post(url:body:onComplete:)
method.
struct MovieBody: Encodable {
let name: String
}
let body = MovieBody(name: "A New Movie")
NetworkPost().post(url: url, body: body) { (result: Result<Movie>) in
// ...
}
Usage in Tests
In test target code you can create your own Getable
(or Postable
as you needed) mock.
public class MockGet: Getable {
var decodableMock: Decodable!
public func get<Entity: Decodable>(url: URL, completionHandler: @escaping (Result<Entity>) -> Void) {
get(url: url.absoluteString, completionHandler: completionHandler)
}
public func get<Entity: Decodable>(url: String, completionHandler: @escaping (Result<Entity>) -> Void) {
if let decodableMock = decodableMock as? Entity {
completionHandler(.success(decodableMock))
}
}
}
And instead NetworkGet
you will use to test the MockGet
on MoviesController
class MoviesControllerTests: XCTestCase {
func testDidTouchAtListMoviesWhenHasMoviesThenPresentAllMovies() {
let mockGet = MockGet()
let movies = [Movie(name: "Star Wars")]
mockGet.decodableMock = movies
let controller = MoviesController(getRequest: mockGet)
controller.didTouchAtListMovies()
XCTAssertEqual(controller.moviesQuantity, movies.count)
}
}
Frisbee Next Features
- [x] Get request
- [x] Create Carthage distribution
- [x] Create Cocoapod distribution
- [x] Query parameter builder
- [ ] Issue # 8 Implement other HTTP verbs
- [ ] Issue # 7 Ready for use mock
- [ ] Issue # 2 Propagate Swift Errors
Telegram
To collaborate, resolve questions and find out what's new about the Frisbee library, join the group on Telegram: https://t.me/FrisbeeLib