• Stars
    star
    267
  • Rank 148,603 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A convenient wrapper around the UI code that is often needed for displaying debug menus.

Yoshi

Travis build status Cocoapods Compatible Platform Swift Docs Carthage compatible

Description

A helpful companion for your iOS app.

Yoshi is a convenient wrapper around the UI code that is often needed for displaying debug menus.

iPhone

Yoshi.gif

iPad

Yoshi_iPad.gif

Requirements

  • iOS 8.0+
  • Xcode 8.0+

Installation

CocoaPods

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

Swift 4.2
pod 'Yoshi'
Swift 3.0
pod 'Yoshi', '2.2.2'
Swift 2.3
pod 'Yoshi', '1.1.1'
Subspec

Starting from version 3, Yoshi provides implementations for some common debugging tasks and category them in its subspecs, including:

To install, specify the subspec in your project's Podfile:

pod 'Yoshi', :subspecs => ['QAKit']

Carthage

You can also add Yoshi to your project using Carthage. Add the following to your Cartfile:

github "prolificinteractive/Yoshi"

Usage

To display Yoshi, simply set up the menu and present it.

// Setup the custom menus
Yoshi.setupDebugMenu([environmentMenu, instabugMenu, dateSelectionMenu])

// Invoke Yoshi
Yoshi.show()

By default, Yoshi will display your app's icon, along with the current build and version number.

Yoshi can be set up to display any sort of menu as long as the menu object conforms to YoshiGenericMenu. Action menu and single selection menus are available out of the box, with several easy-to-conform menu protocols providing flexibility to customize the cells.

Action Menu

Action Menu is the simplest Yoshi menu able to execute custom events when tapped.

For example, we can invoke Instabug when a custom menu is selected.

let instabugMenu = YoshiActionMenu(title: "Start Instabug",
                                   subtitle: nil,
                                   completion: { Instabug.invoke() })

Single Selection Menu

To display a single selection menu, just construct a YoshiSingleSelectionMenu with necessary information as below:

// Build necessary options.
let option1 = YoshiSingleSelection(title: "Option1", subtitle: "Select to push")
let option2 = YoshiSingleSelection(title: "Option2", subtitle: "Select to present")
let option3 = YoshiSingleSelection(title: "Option3", subtitle: "Select to dismiss")
let options: [YoshiTableViewMenuItem] = [option1, option2, option3]

// Construct YoshiSingleSelectionMenu.
let singleSelectionMenu = YoshiSingleSelectionMenu(title: "Options",
                                                   options: options,
                                                   selectedIndex: 0,
                                                   didSelect: { selection in /*Select the option based on selection*/ })

Yoshi will take care of managing selections and call back the convenient closure function when a new selection is made.

Date Selector Menu

To present a date selector menu, create a type that conforms to YoshiDateSelectorMenu protocol

final class DateSelectorMenu: YoshiDateSelectorMenu {

    var title: String
    var subtitle: String?
    var selectedDate: Date
    var didUpdateDate: (dateSelected: Date) -> ()

    init(title: String,
         subtitle: String? = nil,
         selectedDate: Date = Date(),
         didUpdateDate: (Date) -> ()) {
        self.title = title
        self.subtitle = subtitle
        self.selectedDate = selectedDate
        self.didUpdateDate = didUpdateDate
    }

}
let dateSelectorMenu = DateSelectorMenu(title: "Environment Date",
    subtitle: nil,
    didUpdateDate: { (dateSelected) in
      // Do something with the selected date here
})

Submenu

If you find your debug menu getting out of hand, you can organize it into submenus. To do so, just create a type that conforms to YoshiSubmenu:

final class Submenu: YoshiSubmenu {

    let title: String

    let subtitle: String?

    let options: [YoshiGenericMenu] {

}
let integrationsSubmenu = Submenu(title: "Third Party Integrations",
    subtitle: nil,
    options: [
        instabugMenu,
        crashlyticsMenu
    ]
)

Invocation Options

Yoshi can be invoked with a number of different options. The simplest way is to manually invoke using the show() function.

Yoshi.show()

In addition to the vanilla invocation option, Yoshi can also be invoked in response of 3 different options of motion or touch events.
If you want to enable all of those 3 following options you can simply pass the all option to the setupDebugMenu, although this option is already the default one.

Yoshi.setupDebugMenu([/* YoshiMenu items */], invocations: [.all])
/// Or simply
Yoshi.setupDebugMenu([/* YoshiMenu items */])

To specify which option you want exactly you just need to pass the ones you want to the setupDebugMenu function like this:

  • To invoke Yoshi in response to a shake-motion gesture, add the shakeMotionGesture option in the setupDebugMenu invocations parameter as follows.
Yoshi.setupDebugMenu([/* YoshiMenu items */], invocations: [.shakeMotionGesture])
  • To invoke Yoshi in in response to a multi-touch event, add the multiTouch option in the setupDebugMenu invocations parameter as follows.
Yoshi.setupDebugMenu([/* YoshiMenu items */], invocations: [.multiTouch])
  • Finally, to invoke Yoshi in response to a 3D touch event, add the forceTouch option in the setupDebugMenu invocations parameter as follows.
Yoshi.setupDebugMenu([/* YoshiMenu items */], invocations: [.forceTouch])

Extra features

Clipboard copy

Long press on any cell of the Yoshi Menu to copy the subtitle.

Custom your cell UI

You can custom Yoshi menu cells using nib file or programmatically.
To do so, simply create a YoshiGenericMenu and a YoshiResuableCellDataSource:

To support custom UI, first, provide a YoshiResuableCellDataSource instance referencing to your custom cell.

  • With Nib file
private final class CustomMenuCellDataSource: YoshiResuableCellDataSource {

    static var nib: UINib? {
        // Return your Nib file here
        return UINib(nibName: "CustomCell", bundle: nil)
    }

    func cellFor(tableView: UITableView) -> UITableViewCell {
    	// Dequeue and cast the cell here like you would normally did
        guard let cell = (tableView.dequeueReusableCell(withIdentifier: CustomMenuCellDataSource.reuseIdentifier)) as? CustomCell else {
            fatalError()
        }
        // config your cell here
        cell.label.text = "This is a custom cell"
        return cell
    }
}
  • Without Nib file
private final class CustomMenuCellDataSource: YoshiResuableCellDataSource {

	func cellFor(tableView: UITableView) -> UITableViewCell {
    	// Dequeue the cell here like you would normally did, handle the case when deque failed
        guard let cell = (tableView.dequeueReusableCell(withIdentifier: CustomMenuCellDataSource.reuseIdentifier) ??
            UITableViewCell(style: .subtitle, reuseIdentifier: CustomMenuCellDataSource.reuseIdentifier)) as? CustomCell else {
                fatalError()
        }
        // config your cell here
        cell.label.text = "This is a custom cell"
        return cell
    }
}

Then, provide the menu that conforms to YoshiGenericMenu referencing to the data source.

struct MenuWithCustomUI: YoshiGenericMenu {

    var cellSource: YoshiResuableCellDataSource {
        return CustomMenuCellDataSource()
    }

    func execute() -> YoshiActionResult {
        // Do soomething here when the cell is tapped
        return .Handled
    }
}

Finally, display this custom menu like a normal Yoshi menu.

Yoshi.setupDebugMenu([MenuWithCustomUI()])
Yoshi.show()

Contributing to Yoshi

To report a bug or enhancement request, feel free to file an issue under the respective heading.

If you wish to contribute to the project, fork this repo and submit a pull request. Code contributions should follow the standards specified in the Prolific Swift Style Guide.

License

prolific

Copyright (c) 2017 Prolific Interactive

Yoshi is maintained and sponsored by Prolific Interactive. It may be redistributed under the terms specified in the LICENSE file.

More Repositories

1

material-calendarview

A Material design back port of Android's CalendarView
Java
5,903
star
2

ParallaxPager

Add some depth to your Android scrolling.
Java
779
star
3

Caishen

A Payment Card UI & Validator for iOS
Swift
762
star
4

Chandelier

A nice swipe layout that provides new actions with a material design look and feel
Java
240
star
5

swift-style-guide

A style guide for Swift.
172
star
6

SamMitiAR-iOS

Ready-and-easy-to-use ARKit framework for the best user experience.
Swift
120
star
7

node-html-to-json

Parses HTML strings into objects using flexible, composable filters.
JavaScript
119
star
8

PIDatePicker

[DEPRECATED] A customizable implementation of UIDatePicker, written in Swift.
Swift
39
star
9

navigation-conductor

A Conductor integration for the Navigation Architecture Component.
Kotlin
38
star
10

NavigationControllerBlurTransition

[DEPRECATED] A UINavigationController transition that utilizes a blur view for a simple interface.
Swift
35
star
11

android-studio-templates

A set of templates for your Android Studio
FreeMarker
35
star
12

HouseOfCards

Android tools for working with a house of (credit) cards
Java
27
star
13

Optik

A Swift library for displaying images from any source, local or remote.
Swift
25
star
14

PIAPIEnvironmentManager

[DEPRECATED] A simple manager for handling the various API Environments in your project.
Objective-C
20
star
15

simcoe

A simple, light analytics framework for iOS.
Swift
19
star
16

SOLID-Principles

Exploring the SOLID Principles in Swift. Video: https://www.youtube.com/watch?v=gkxmeWvGEpU&t=2s
Swift
19
star
17

anchored-behavior

A CoordinatorLayout Behavior to anchor views with an animation.
Kotlin
17
star
18

Marker

A light wrapper around NSAttributedString.
Swift
15
star
19

Kumi-iOS

Swift
15
star
20

TouchIDBlogPost

Accompanies the tutorial "Use Touch ID in Your Swift App"
Swift
12
star
21

Bellerophon

Swift
12
star
22

Pilas

A scrollable stackview.
Swift
9
star
23

applepay-demo

Objective-C
9
star
24

mabi

Start your REST Mobile APIs Fast and Build as you Grow
C
8
star
25

heimdall

A simple validation check overview for you password fields.
Java
8
star
26

PIVideoPlayer

[DEPRECATED] A custom wrapper around AVFoundation for playing silent video files without any chrome.
Objective-C
7
star
27

Velar

A custom alert view presenter.
Swift
6
star
28

geocoder

This is a device independent and plugable replacement for Android's builtin Geocoder.
Kotlin
6
star
29

ShimmerBlocks

Add blocked shimmering views to your view components.
Swift
5
star
30

Cake

[DEPRECATED] A Cocoapods wrapper allowing for greater control over your workspaces
Swift
5
star
31

ballad

Assemble API Blueprint specs with concatenation, templating, and inheritance.
HTML
4
star
32

patrons

SharedPreferences wrappers with an encryption package.
Kotlin
3
star
33

DeathStar

Sample project for the "Conquering the Testing Beast" talk for Swift Camp (http://swiftcamp.io/)
Swift
3
star
34

behalf

Emulate the way browsers make requests and manage cookies.
JavaScript
3
star
35

TickerCounter

A counter with a ticker animation.
Swift
2
star
36

simplesamlphp-module-mongodb

SimpleSAML Store implementation for MongoDB PHP Library
PHP
2
star
37

data-builder

A build tool for JSON and YAML that uses special keys to specify functions, i.e. $import.
JavaScript
2
star
38

flutter_debug_menu

Flutter Debug Menu
Dart
2
star
39

Birdo

Prolific's android wrapper around the UI code that is often needed for displaying debug menus.
Kotlin
1
star
40

glenlivet

Create flexible, reusable processing pipelines powered by plugins.
JavaScript
1
star
41

mabiSkeletonApi

PHP
1
star
42

Olapic-SDK-iOS

Objective-C
1
star
43

prolific-cleaner

Sets up javascript projects to be linted and checked for code styles based on commit and push git hooks.
JavaScript
1
star
44

IQKeyboardManager

Objective-C
1
star
45

simcoe-android

A simple, light analytics framework for Android.
Kotlin
1
star
46

DevKit

Collection of commonly used swift code
Swift
1
star
47

simplesamlphp-module-mongo

SimpleSAML Store implementation for MongoDB
PHP
1
star
48

PIPassiveAlert

[DEPRECATED] A passive alert library in Objective-C. 🚨
Objective-C
1
star
49

pandroid-gradle-plugin

The PAndroid Gradle plugin allows all Prolific's Android project to run on our CI pipeline for different build variants.
Groovy
1
star
50

artgun-php

PHP ArtGun API Wrapper
PHP
1
star