Latest 0.2.1
Homepage https://github.com/davelyon/CheatCodes
License MIT
Platforms ios 8.0
Authors

Version
License
Platform
Documentation

About

CheatCodes is a drop in tool to enable debugging functionality in the simulator by using UIKeyCommand. It also provides tools to build your own custom commands with formatted output.

The following commands are available by default:

Available Cheat Codes:
======================
 ⌘ + ⇧ + ^ + ↓: Trigger restorable state preservation
     ⇧ + ^ + d: Print documents directory path
     ⇧ + ^ + e: Re-enable user interaction
     ⇧ + ^ + h: Print the list of available commands
     ⇧ + ^ + i: Print general device info
     ⇧ + ^ + l: Print autolayout backtrace
     ⇧ + ^ + o: Print the current trait collection (for the main window)
     ⇧ + ^ + t: Cycle tintAdjustmentMode
     ⇧ + ^ + u: Print user defaults

WARNING

While this pod is configured to make itself essentially empty for "Release" builds, it’s possible that your project may use an alternate build configuration name for app store releases. You should take care to ensure that this pod is not available in any publicly available builds.

Using

Flags

In Xcode 8, add to your project under Active Compilation Conditions (SWIFT_ACTIVE_COMPILATION_CONDITIONS):

Active Compilation Conditions > Debug > CHEATS_ENABLED

Basic Usage

class AppDelegate {
#if CHEATS_ENABLED
  override var keyCommands: [UIKeyCommand]? {
    return UIKeyCommand.cheatCodes
  }
#endif
}

Adding Custom Commands

#if CHEATS_ENABLED
extension AppDelegate {

    func configureCustomCheats() {
        [
            CheatCodeCommand(input: "g", action: #selector(logInUser), discoverabilityTitle: "Log in a default user account"),
            CheatCodeCommand(input: "f", modifierFlags: [.command, .alternate], action: #selector(resetFirstRunScreens), discoverabilityTitle: "Reset all first run screens"),

        ].forEach { UIKeyCommand.addCheatCode($0) }

    }

    func logInUser() {
        print("Log in a user")
    }

    func resetFirstRunScreens() {
        print("First run screens reset!")
    }
}
#endif

Notes

While you will not see the overlay that hints at which items are available, these do in fact work on the iPhone simulators (make sure Hardware > Keyboard > Connect Hardware Keyboard is enabled)

Example

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

Requirements

  • Swift 3.0+
  • iOS 8+

Installation

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

pod "CheatCodes"

Author

Dave Lyon, [email protected]

License

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

Latest podspec

{
    "name": "CheatCodes",
    "version": "0.2.1",
    "summary": "UIKeyCommand shortcuts for debugging applications in the simulator",
    "description": "CheatCodes is a drop in tool to enable some basic debugging functionality in the simulator by using `UIKeyCommand`.nnCurrently, it ships with the following already available:nn```nAvailable Cheat Codes:n======================n u2318 + u21e7 + ^ + u2193: Trigger restorable state preservationn     u21e7 + ^ + d: Print documents directory pathn     u21e7 + ^ + e: Re-enable user interactionn     u2318 + u2325 + f: Reset all first run screensn     u21e7 + ^ + g: Log in a default user accountn     u21e7 + ^ + h: Print the list of available commandsn     u21e7 + ^ + i: Print general device infon     u21e7 + ^ + l: Print autolayout backtracen     u21e7 + ^ + o: Print the current trait collection (for the main window)n     u21e7 + ^ + t: Cycle tintAdjustmentModen     u21e7 + ^ + u: Print user defaultsn```",
    "homepage": "https://github.com/davelyon/CheatCodes",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Dave Lyon": "[email protected]"
    },
    "source": {
        "git": "https://github.com/davelyon/CheatCodes.git",
        "tag": "0.2.1"
    },
    "social_media_url": "https://twitter.com/daveisonthego",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "CheatCodes/Classes/**/*",
    "pod_target_xcconfig": {
        "SWIFT_ACTIVE_COMPILATION_CONDITIONS": "CHEAT_${CONFIGURATION}",
        "SWIFT_VERSION": "3.0"
    }
}

Pin It on Pinterest

Share This