{"id":21065054,"url":"https://github.com/prolificinteractive/yoshi","last_synced_at":"2025-04-06T16:13:13.537Z","repository":{"id":4010709,"uuid":"48459457","full_name":"prolificinteractive/Yoshi","owner":"prolificinteractive","description":"A convenient wrapper around the UI code that is often needed for displaying debug menus.","archived":false,"fork":false,"pushed_at":"2022-07-22T01:13:50.000Z","size":23195,"stargazers_count":266,"open_issues_count":10,"forks_count":27,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-03-30T14:11:27.846Z","etag":null,"topics":["carthage","cocoapods","custom-menus","debug","ios","menus","yoshi"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prolificinteractive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-22T23:50:42.000Z","updated_at":"2024-11-27T02:34:27.000Z","dependencies_parsed_at":"2022-08-06T14:30:31.372Z","dependency_job_id":null,"html_url":"https://github.com/prolificinteractive/Yoshi","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2FYoshi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2FYoshi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2FYoshi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2FYoshi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prolificinteractive","download_url":"https://codeload.github.com/prolificinteractive/Yoshi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509236,"owners_count":20950232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carthage","cocoapods","custom-menus","debug","ios","menus","yoshi"],"created_at":"2024-11-19T17:53:18.717Z","updated_at":"2025-04-06T16:13:13.515Z","avatar_url":"https://github.com/prolificinteractive.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Yoshi](Images/Yoshi_logo.jpg)\n\n[![Travis build status](https://img.shields.io/travis/prolificinteractive/Yoshi.svg?style=flat-square)](https://travis-ci.org/prolificinteractive/Yoshi)\n[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/Yoshi.svg?style=flat-square)](https://img.shields.io/cocoapods/v/Yoshi.svg)\n[![Platform](https://img.shields.io/cocoapods/p/Yoshi.svg?style=flat-square)](http://cocoadocs.org/docsets/Yoshi)\n[![Swift](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat-square)](http://cocoadocs.org/docsets/Yoshi)\n[![Docs](https://img.shields.io/cocoapods/metrics/doc-percent/Yoshi.svg?style=flat-square)](http://cocoadocs.org/docsets/Yoshi)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n## Description\n\nA helpful companion for your iOS app.\n\nYoshi is a convenient wrapper around the UI code that is often needed for displaying debug menus.\n\n### iPhone\n![Yoshi.gif](Images/Yoshi.gif)\n\n### iPad\n![Yoshi_iPad.gif](Images/Yoshi_iPad.gif)\n\n## Requirements\n\n* iOS 8.0+\n* Xcode 8.0+\n\n## Installation\n\n### CocoaPods\nYoshi is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your `Podfile`:\n\n###### Swift 4.2\n\n```ruby\npod 'Yoshi'\n```\n\n###### Swift 3.0\n\n```ruby\npod 'Yoshi', '2.2.2'\n```\n\n###### Swift 2.3\n\n```ruby\npod 'Yoshi', '1.1.1'\n```\n\n###### Subspec\n\nStarting from version 3, Yoshi provides implementations for some common debugging tasks and category them in its subspecs, including:\n\n* [QAKit](Yoshi/QAKit/README.md)\n\nTo install, specify the subspec in your project's Podfile:\n\n```ruby\npod 'Yoshi', :subspecs =\u003e ['QAKit']\n```\n\n### Carthage\nYou can also add Yoshi to your project using [Carthage](https://github.com/Carthage/Carthage). Add the following to your `Cartfile`:\n\n```ruby\ngithub \"prolificinteractive/Yoshi\"\n```\n\n## Usage\n\nTo display Yoshi, simply set up the menu and present it.\n\n```swift\n\n// Setup the custom menus\nYoshi.setupDebugMenu([environmentMenu, instabugMenu, dateSelectionMenu])\n\n// Invoke Yoshi\nYoshi.show()\n```\n\nBy default, Yoshi will display your app's icon, along with the current build and version number.\n\nYoshi 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.\n\n### Action Menu\n\nAction Menu is the simplest Yoshi menu able to execute custom events when tapped.\n\nFor example, we can invoke [Instabug](https://instabug.com) when a custom menu is selected.\n\n```swift\nlet instabugMenu = YoshiActionMenu(title: \"Start Instabug\",\n                                   subtitle: nil,\n                                   completion: { Instabug.invoke() })\n```\n\n### Single Selection Menu\n\nTo display a single selection menu, just construct a `YoshiSingleSelectionMenu` with necessary information as below:\n\n```swift\n\n// Build necessary options.\nlet option1 = YoshiSingleSelection(title: \"Option1\", subtitle: \"Select to push\")\nlet option2 = YoshiSingleSelection(title: \"Option2\", subtitle: \"Select to present\")\nlet option3 = YoshiSingleSelection(title: \"Option3\", subtitle: \"Select to dismiss\")\nlet options: [YoshiTableViewMenuItem] = [option1, option2, option3]\n\n// Construct YoshiSingleSelectionMenu.\nlet singleSelectionMenu = YoshiSingleSelectionMenu(title: \"Options\",\n                                                   options: options,\n                                                   selectedIndex: 0,\n                                                   didSelect: { selection in /*Select the option based on selection*/ })\n```\n\nYoshi will take care of managing selections and call back the convenient closure function when a new selection is made.\n\n### Date Selector Menu\n\nTo present a date selector menu, create a type that conforms to `YoshiDateSelectorMenu` protocol\n\n```swift\nfinal class DateSelectorMenu: YoshiDateSelectorMenu {\n\n    var title: String\n    var subtitle: String?\n    var selectedDate: Date\n    var didUpdateDate: (dateSelected: Date) -\u003e ()\n\n    init(title: String,\n         subtitle: String? = nil,\n         selectedDate: Date = Date(),\n         didUpdateDate: (Date) -\u003e ()) {\n        self.title = title\n        self.subtitle = subtitle\n        self.selectedDate = selectedDate\n        self.didUpdateDate = didUpdateDate\n    }\n\n}\n```\n\n```swift\nlet dateSelectorMenu = DateSelectorMenu(title: \"Environment Date\",\n    subtitle: nil,\n    didUpdateDate: { (dateSelected) in\n      // Do something with the selected date here\n})\n```\n\n### Submenu\n\nIf 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:\n\n\n```swift\nfinal class Submenu: YoshiSubmenu {\n\n    let title: String\n\n    let subtitle: String?\n\n    let options: [YoshiGenericMenu] {\n\n}\n```\n\n```swift\nlet integrationsSubmenu = Submenu(title: \"Third Party Integrations\",\n    subtitle: nil,\n    options: [\n        instabugMenu,\n        crashlyticsMenu\n    ]\n)\n```\n\n### Invocation Options\n\nYoshi can be invoked with a number of different options. The simplest way is to manually invoke using the `show()` function.\n\n```swift\nYoshi.show()\n```\n\nIn addition to the vanilla invocation option, Yoshi can also be invoked in response of 3 different options of motion or touch events.   \nIf 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.\n\n```swift\nYoshi.setupDebugMenu([/* YoshiMenu items */], invocations: [.all])\n/// Or simply\nYoshi.setupDebugMenu([/* YoshiMenu items */])\n```\n\nTo specify which option you want exactly you just need to pass the ones you want to the `setupDebugMenu` function like this:\n\n* To invoke Yoshi in response to a shake-motion gesture, add the `shakeMotionGesture` option in the `setupDebugMenu` invocations parameter as follows.\n\n```swift\nYoshi.setupDebugMenu([/* YoshiMenu items */], invocations: [.shakeMotionGesture])\n```\n\n* To invoke Yoshi in in response to a multi-touch event, add the `multiTouch` option in the `setupDebugMenu` invocations parameter as follows.\n\n```swift\nYoshi.setupDebugMenu([/* YoshiMenu items */], invocations: [.multiTouch])\n```\n\n* Finally, to invoke Yoshi in response to a 3D touch event, add the `forceTouch` option in the `setupDebugMenu` invocations parameter as follows.\n\n```swift\nYoshi.setupDebugMenu([/* YoshiMenu items */], invocations: [.forceTouch])\n```\n\n### Extra features\n\n#### Clipboard copy\nLong press on any cell of the Yoshi Menu to copy the subtitle.\n\n#### Custom your cell UI\n\nYou can custom Yoshi menu cells using nib file or programmatically.   \nTo do so, simply create a `YoshiGenericMenu` and a `YoshiResuableCellDataSource`:\n\nTo support custom UI, first, provide a `YoshiResuableCellDataSource` instance referencing to your custom cell.      \n\n* With Nib file\n\n```swift\nprivate final class CustomMenuCellDataSource: YoshiResuableCellDataSource {\n\n    static var nib: UINib? {\n        // Return your Nib file here\n        return UINib(nibName: \"CustomCell\", bundle: nil)\n    }\n\n    func cellFor(tableView: UITableView) -\u003e UITableViewCell {\n    \t// Dequeue and cast the cell here like you would normally did\n        guard let cell = (tableView.dequeueReusableCell(withIdentifier: CustomMenuCellDataSource.reuseIdentifier)) as? CustomCell else {\n            fatalError()\n        }\n        // config your cell here\n        cell.label.text = \"This is a custom cell\"\n        return cell\n    }\n}\n```\n\n* Without Nib file\n\n```swift\nprivate final class CustomMenuCellDataSource: YoshiResuableCellDataSource {\n\n\tfunc cellFor(tableView: UITableView) -\u003e UITableViewCell {\n    \t// Dequeue the cell here like you would normally did, handle the case when deque failed\n        guard let cell = (tableView.dequeueReusableCell(withIdentifier: CustomMenuCellDataSource.reuseIdentifier) ??\n            UITableViewCell(style: .subtitle, reuseIdentifier: CustomMenuCellDataSource.reuseIdentifier)) as? CustomCell else {\n                fatalError()\n        }\n        // config your cell here\n        cell.label.text = \"This is a custom cell\"\n        return cell\n    }\n}\n```\n\nThen, provide the menu that conforms to `YoshiGenericMenu` referencing to the data source.\n\n```swift\nstruct MenuWithCustomUI: YoshiGenericMenu {\n\n    var cellSource: YoshiResuableCellDataSource {\n        return CustomMenuCellDataSource()\n    }\n\n    func execute() -\u003e YoshiActionResult {\n        // Do soomething here when the cell is tapped\n        return .Handled\n    }\n}\n```\n\nFinally, display this custom menu like a normal Yoshi menu.\n\n```swift\nYoshi.setupDebugMenu([MenuWithCustomUI()])\nYoshi.show()\n```\n\n## Contributing to Yoshi\n\nTo report a bug or enhancement request, feel free to file an issue under the respective heading.\n\nIf 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](https://github.com/prolificinteractive/swift-style-guide).\n\n## License\n\n![prolific](https://s3.amazonaws.com/prolificsitestaging/logos/Prolific_Logo_Full_Color.png)\n\nCopyright (c) 2017 Prolific Interactive\n\nYoshi is maintained and sponsored by Prolific Interactive. It may be redistributed under the terms specified in the [LICENSE] file.\n\n[LICENSE]: ./LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprolificinteractive%2Fyoshi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprolificinteractive%2Fyoshi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprolificinteractive%2Fyoshi/lists"}