Swiftpack.co -  mokten/StubPlay as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Save and replay http requests in Swift
.package(url: "https://github.com/mokten/StubPlay.git", from: "v0.1.9")


Save and replay http requests in Swift

Stubs http responses and supports any http response including text, html, json, images, videos and HLS.

CocoaPods Compatible Carthage Compatible Platform

  1. Features
  2. Requirements
  3. Compatible
  4. Installation
  5. Usage
    1. Usage
    2. Unit Test
  6. Concepts
  7. License


  • ☑ Saves full http request and responses
  • ☑ Unit tests are easy - no more having to write a bunch of boilerplate code for the network layer
  • ☑ Automated UI tests are easy too
  • ☑ Audit responses
    1. Server side dev said they didn’t change anything but you can prove they did because you saved the responses
  • ☑ Api not ready? That’s ok you can create your own stubs and use them until the api is ready
  • ☑ Debug http requests - view requests being saved as responses are being consumed by your App
  • ☑ Replay customer experiences -> need to upload to your server yourself


  • iOS 10.0+ / tvOS 11.0+
  • Xcode 11.3+
  • Swift 5.1+


Swift Package Manager (SPM)

dependencies: [
    .package(name: "StubPlay", url: "https://github.com/mokten/StubPlay.git", .upToNextMajor(from: "0.1.11"))


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

  • Cocoapods 1.7+
$ gem install cocoapods

CocoaPods 1.7+ is required to build StubPlay

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

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'

target '<Your Target Name>' do
    pod 'StubPlay'

Then, run the following command:

$ pod install


  • Carthage 0.33+


github "mokten/StubPlay"


We recommend enabling stubs as soon as possible - in your main.swift file or App delegate init()

By default: requests/response are saved in the caches/com.mokten.stubplay directory. Every time the app is run this directory will be cleared out.

Add a reference folder to your app. ie. "Stub/default", this is where your stubs will be read from

import StubPlay

// This will save all requests and responses to the app cache directory
// Start the app and navigate around
// Once you have completed your scenario then copy the files in the cache directory to your reading stub directory "Stub/default"
try? StubPlay.default.enableStub(for: StubConfig(folders: ["Stub/default"],
                                                 saveResponses: true,
                                                 isEnabledServer: true,
                                                 isLogging: true))

_ = UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, NSStringFromClass(Application.self), NSStringFromClass(AppDelegate.self))


import UIKit
import StubPlay

class AppDelegate: UIResponder, UIApplicationDelegate {

    override init() {
        try? StubPlay.default.enableStub(for: StubConfig(folders: ["Stub/default"],
                                                         saveResponses: true,
                                                         isEnabledServer: true,
                                                         isLogging: true))

Optionally, all requests are saved to the Caches directory (this can be turned off with configuration):

ie: ~/Library/Developer/CoreSimulator/Devices/C62F6E5A-6459-45B6-B20B-B7C8E07AA529/data/Containers/Data/Application/1C1E61F8-B7B9-45FA-AA7E-7928E8952989/Library/Caches/com.mokten.stubplay


  1. Stubbed request / response has 2 files
  2. request+response/rewrite rule file -> json format
  3. response body file -> native format

The response body is in its own file so that it can be easily be used by viewers/editers ie. image, json, text, html, videos


StubPlay is released under the MIT license. See LICENSE for details.


Stars: 0
Last commit: 5 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.


Release Notes

Added SPM support
14 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API