项目主页    by: ronanrodrigo     Star:    Fork:     


Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application.

Build Status CocoaPods CocoaPods Carthage codecov codebeat badge Join at Telegram Linux Compatible



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

github "ronanrodrigo/Frisbee" ~> 0.1.6

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


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

source ''
platform :ios, '10.0'

target '<Your Target Name>' do
    pod 'Frisbee', '0.1.6'

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: "", from: "0.1.6")
    targets: [
        .target(name: "<Your Packege Name>", dependencies: ["Frisbee"])


Create a decodable entity

struct Movie: Decodable {
    let name: String

This is an example of some code that will request some data across network

class MoviesController {
    private let getRequest: Getable
    var moviesQuantity = 0
    // Expect something that conforms to Getable
    init(getRequest: Getable) {
        self.getRequest = getRequest

    func didTouchAtListMovies() {
        getRequest.get(url: "") { (moviesResult: Result<[Movie]>) in
            switch moviesResult {
                case let .success(movies): self.moviesQuantity = movies.count
                case let .fail(error): print(error)

In production-ready code you must inject an instance of NetworkGetter.

// Who will call the MoviesController must inject a NetworkGetter instance
MoviesController(getRequest: NetworkGetter())

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)
NetworkGetter().get(url: url, query: query) { (result: Result<Movie>) in
    // ...

Usage in tests

In test target code you can create your own Getable mock.

public class MockGetter: 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 {


And instead NetworkGetter you will use to test the MockGetter on MoviesController

class MoviesControllerTests: XCTestCase {
    func testDidTouchAtListMoviesWhenHasMoviesThenPresentAllMovies() {
        let mockGet = MockGetter()
        let movies = [Movie(name: "Star Wars")]
        mockGet.decodableMock = movies
        let controller = MoviesController(getRequest: mockGet)


        XCTAssertEqual(controller.moviesQuantity, movies.count)

Frisbee next features

  • Get request
  • Create Carthage distribution
  • Create Cocoapod distribution
  • Query parameter builder
  • Issue # 8 Implement other HTTP verbs
  • Issue # 7 Ready for use mock
  • Issue # 2 Propagate Swift Errors


To collaborate, resolve questions and find out what's new about the Frisbee library, join the group on Telegram: