Toybox

Build Status GitHub license GitHub release Language

Toybox 简化了 Xcode Playgrounds 的管理。

您可以通过 CLI 创建和打开 Xcode Playground。

$ toybox create Snippet
# Generate ~/.toybox/Snippet.playground and open with Xcode

本产品仍在开发中,界面可能会发生变化。

使用 Toybox 之前

使用 Toybox

安装

Toybox 需要 High Sierra 或更高版本。

Homebrew

$ brew tap giginet/toybox https://github.com/giginet/Toybox.git
$ brew install giginet/toybox/toybox
$ toybox version

如果在 tapping formula 时出现错误,请先尝试 brew untap giginet/toybox

Mint

安装 yonaskolb/Mint

$ mint install giginet/toybox

功能

创建新的 Playground

# Create 'UIKitDemo.playground' for iOS
$ toybox create UIKitDemo
# Create a new Playground which is not saved
$ toybox create
# Create a new auto generated named Playground which is saved like 20190404082446.playground
$ toybox create -s
# Create 'SpriteKit.playground' for macOS
$ toybox create SpriteKitDemo --platform macos
# Overwrite existing playground 'UIKitDemo'
$ toybox create UIKitDemo -f
# Create but don't open with Xcode
$ toybox create UIKitDemo --no-open
# Create and open with specific Xcode
$ toybox create UIKitDemo --xcode-path /Application/Xcode7.3.app
$ toybox create UIKitDemo --xcode-version 11.1
# Create Playground from standard input
$ echo 'print("Hello World")' | toybox create --input

创建的 Playgrounds 将保存在 $HOME/.toybox 目录下

列出 Playgrounds

# List all existing playgrounds
$ toybox list
# List all playgrounds of specific platform
$ toybox list --platform ios

打开 Playground

# Open UIKitDemo.playground with default Xcode
$ toybox open UIKitDemo
# Open UIKitDemo.playground with specific Xcode
$ toybox open UIKitDemo --xcode-path /Application/Xcode7.3.app
$ toybox open UIKitDemo --xcode-version 11.1

其他

# Display current Toybox version
$ toybox version
# Display path to Toybox root directory,
# It should return '$HOME/.toybox'
$ toybox root

额外用法

通过 peco 打开现有 playgrouds

toybox list | peco | awk '{print $1}' | xargs toybox open

开发

Xcode 11

直接使用 Xcode 11 打开 Toybox 目录。

在 Xcode 10.2 下

$ swift package generate-xcodeproj
$ open Toybox.xcodeproj

作者

giginet <giginet.net@gmail.com>

许可证

MIT 许可证