Latest 0.1.0
Homepage https://github.com/RosterHQ/rosterdev
License MIT
Platforms ios 8.0
Authors

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

rosterdev is available through CocoaPods. To install
it, add the following line to your Podfile:

pod 'rosterdev', '~> 0.1'

The intent is that these developer functions will only be available in debug builds of your app. To accomplish this in Swift, create a DEBUG OTHER_SWIFT_FLAGS for your debug build.

In your code, do:

import rosterdev

You will also need to enable the developer dashboard to be displayed. One way to do this is via a shake gesture. See the example here:

#if DEBUG
extension UIWindow {
    override open func motionBegan(_ motion: UIEventSubtype, with event: UIEvent?) {
        if motion == .motionShake {
            if let rootVC = UIApplication.shared.keyWindow?.rootViewController {
                RosterDevVC.show(fromViewController: rootVC, rowContents: [], options: .all)
            }
        }
    }
}
#endif

In the above example, if you want to put additional rows of your own design into the developer dashboard, you’ll need to provide a non-empty list to the rowContents: parameter.

The class DebugDashboardData in the Example code provides an example of this:

class DebugDashboardData {
    private init() {
    }

    static let session = DebugDashboardData()

    var debugDashboardExampleSection: [RosterDevRowContents] = {
        var useDev = RosterDevRowContents(name: "Use staging environment", action: { parentVC in
            // Need to do something to setup staging environment
        })
        var useProd = RosterDevRowContents(name: "Use prod environment", action: { parentVC in
            // Need to do something to setup prod environment
        })

        return [useDev, useProd]
    }()

    func sections() -> [[RosterDevRowContents]] {
        return [debugDashboardExampleSection]
    }
}

To use this class, use DebugDashboardData.session.sections() for the rowContents parameter of RosterDevVC.show.

If you are doing test injection, you will need:

#if DEBUG
    TestCases.setup()
#endif

in your AppDelegate. See the example here:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
#if DEBUG
    TestCases.setup()
#endif
        return true
    }

Where TestCases looks something like:

import Foundation
import rosterdev

class TestCases {
    private init() {
    }

    static let session = TestCases()

    static func setup() {
        _ = session
    }

    // Make these text names fairly short. They are presented in a UI.

    let testFail1 = RosterDevInjectTest.define(testCaseName: "Endpoint1Failure")
    let testFail2 = RosterDevInjectTest.define(testCaseName: "Endpoint2Failure")
    ...
}

You will also need, of course, to inject some actual tests in your code. For example, this would look something like:

RosterDevInjectTest.if(TestCases.session.testFail1) {
    // This will only get executed if the DEBUG flag is set AND testFail1 is turned on from the developer dashboard.
    // So, do whatever test injection you need to do here.
}

Author

crspybits, [email protected]

License

rosterdev is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "rosterdev",
    "version": "0.1.0",
    "summary": "A developer dashboard, along with test injection facilities.",
    "description": "Shake your app, when it's built for development (using a DEBUG flag), and bring up a development dashboard. This can be useful to change network API environments. With a default option, you can get a list of tests you can inject-- e.g., to inject artificial errors, for hard to test edge cases, into your running program.",
    "homepage": "https://github.com/RosterHQ/rosterdev",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "crspybits": "[email protected]"
    },
    "source": {
        "git": "https://github.com/RosterHQ/rosterdev.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "rosterdev/Classes/**/*",
    "resources": [
        "rosterdev/Assets/**/*.storyboard"
    ],
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This