• Stars
    star
    662
  • Rank 65,862 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 4 years ago
  • Updated 6 months ago

Reviews

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

Repository Details

A command line tool to create Swift Playground projects with SPM package dependencies

@_sa_s

🏟 Arena

Arena is a macOS command line tool to create an Xcode project with a Swift Playground that's readily set up to use a Swift Package Manager library. You can reference both Github and local repositories. The latter is especially useful to spin up a Playground while working on a library.

Arena demo

Arena can also create a Playground in "Playground Book" format, which is the file format supported by "Swift Playgrounds". These playgrounds can then be synced and opened on the iOS version of "Swift Playgrounds" as well.

Here is an overview of the arena command line interface:

arena --help
OVERVIEW: Creates an Xcode project with a Playground and one or more SPM libraries imported and
ready for use.

USAGE: arena [--book] [--force] [--libs <libs> ...] [--outputdir <outputdir>] [--platform <platform>] [--version] [--skip-open] [<dependencies> ...]

ARGUMENTS:
  <dependencies>          Dependency url(s) and (optionally) version specification

OPTIONS:
  --book                  Create a Swift Playgrounds compatible Playground Book bundle
                          (experimental).
  -f, --force             Overwrite existing file/directory
  -l, --libs <libs>       Names of libraries to import (inferred if not provided)
  -o, --outputdir <outputdir>
                          Directory where project folder should be saved (default:
                          /Users/sas/Projects/Arena/Arena-Playground)
  -p, --platform <platform>
                          Platform for Playground (one of 'macos', 'ios', 'tvos') (default:
                          macos)
  -v, --version           Show version
  --skip-open             Do not open project in Xcode on completion
  -h, --help              Show help information.

Examples

Import Github repository

arena https://github.com/finestructure/Gala
➡️ Package: https://github.com/finestructure/Gala @ from(0.2.1)
🔧 Resolving package dependencies… 
📔 Libraries found: Gala
✅ Created project in folder 'Arena-Playground'

Using Github shorthand syntax

You can skip the protocol and domain when referring to Github projects:

arena finestructure/Gala
➡️ Package: https://github.com/finestructure/Gala @ from(0.2.1)
🔧 Resolving package dependencies…
📔 Libraries found: Gala
✅ Created project in folder 'Arena-Playground'

Import local repository

arena ~/Projects/Parser
➡️ Package: file:///Users/sas/Projects/Parser @ path
🔧 Resolving package dependencies…
📔 Libraries found: Parser
✅ Created project in folder 'Arena-Playground'

Import both

arena ~/Projects/Parser finestructure/Gala
➡️ Package: file:///Users/sas/Projects/Parser @ path
➡️ Package: https://github.com/finestructure/Gala @ from(0.2.1)
🔧 Resolving package dependencies…
📔 Libraries found: Parser, Gala
✅ Created project in folder 'Arena-Playground'

Specifying versions

In case you want to fetch a particular revision, range of revisions, or branch, you can use a syntax similar to the one used in a Package.swift file. Here's what's supported and the corresponding package dependecy that it will create in the generated project:

  • https://github.com/finestructure/[email protected]

    .package(url: "https://github.com/finestructure/Gala", exact: "0.1.0")

  • https://github.com/finestructure/Gala@from:0.1.0

    .package(url: "https://github.com/finestructure/Gala", from: "0.1.0")

  • "https://github.com/finestructure/[email protected]..<4.0.0"

    .package(url: "https://github.com/finestructure/Gala", "0.1.0"..<"4.0.0")

  • https://github.com/finestructure/[email protected]

    .package(url: "https://github.com/finestructure/Gala", "0.1.0"..<"4.0.1")

  • https://github.com/finestructure/Gala@branch:master

    .package(url: "https://github.com/finestructure/Gala", branch: "master")

  • https://github.com/finestructure/Gala@revision:7235531e92e71176dc31e77d6ff2b128a2602110

    .package(url: "https://github.com/finestructure/Gala", revision: "7235531e92e71176dc31e77d6ff2b128a2602110")

Make sure to properly quote the URL if you are using the ..< range operator. Otherwise your shell will interpret the < character as input redirection.

Adding another dependency

Arena does not currently support adding further depenencies to an existing playground. However, since its dependencies are managed via the Dependencies package, you can simply add further entries to its Package.swift file - just like you would when extending any other package manifest.

Here's what this looks like:

Adding a dependency

How to install Arena

Homebrew

You can install Arena with Homebrew:

brew install finestructure/tap/arena

Mint

You can install Arena with Mint:

mint install finestructure/arena

Make

Last not least, you can build and install arena via the included Makefile by running:

make install

This will copy the binary arena to /usr/local/bin.

Overriding the default playground code

Be default, Arena adds import statements for the library targets it finds in a package.

As a package author, you can override this behaviour by adding a file .arena-sample.swift to the top level of your repository. The contents of this file will be used as the playground source code.

Parser is a Swift package that comes with a .arena-sample.swift file.

Why Arena?

Arena – Spanish for "sand" – is abundant in playgrounds. And also, sometimes you've got to take your source code to the arena for a fight 😅

Compatibility

Starting with version 1.0, arena requires Xcode 12. Xcode 12 brings a number of improvements that make playgrounds work much better than previous versions of Xcode. Also, arena now creates a simpler project structer that can be manually edited to add more dependencies.

If you want to use arena with Xcode 11, please use the latest 0.x release.

Playground books created by arena should run on macOS as well as iOS. Please bear in mind that the Swift packages you import when creating playground books will need to be iOS compatible.

Note that while creating playgrounds requires macOS 10.15+ and Swift 5.3, the resulting playgrounds should be supported on a wider range of operating system and compiler versions. This will mainly depend on the packages you are importing.

More Repositories

1

CoPilot

Swift
275
star
2

Hummingbird

A macOS utility that makes window management a breeze
Swift
191
star
3

Gala

Create SwiftUI preview variants for macOS, iOS, tvOS, and watchOS with ease
Swift
87
star
4

Historian

History viewer and transmitter for Composable Architecture apps
Swift
55
star
5

Rester

A command line tool to test (REST) APIs
Swift
42
star
6

blogpost-prometheus

Source code for blog post 'Monitoring with Prometheus, Grafana & Docker'
Dockerfile
19
star
7

PFCompArch

This is an example project for the "Composable Architecture" introduced by pointfree.co
Swift
14
star
8

ImageAttributesPublishPlugin

A Publish plugin to add support for image attributes
Swift
8
star
9

DiffMatchPatch

Swift package for Google’s Diff Match Patch
Objective-C
7
star
10

CRabbitMQ

A swift package manager wrapper for rabbitmq-c
C
6
star
11

ValueCodable

A Value struct to decode arbitrary data
Swift
6
star
12

autotm

Script that automatically switches between several configured time machine backup servers
Ruby
6
star
13

homebrew-tap

Ruby
3
star
14

Sms2Mail

Upload iPhone SMS (text messages) to an IMAP mail account
Python
3
star
15

Parser

Library to create composable parsers, based on pointfree.co's series on Parsing
Swift
3
star
16

RabbitMQ

ObjC Framework wrapper for rabbitmq-c
C
2
star
17

HistoryTransceiver

Swift
2
star
18

CompArch

SwiftUI State-Action-Reducer architecture based on pointfree.co series
Swift
2
star
19

AsyncTest

SenTestCase+Async category and usage example
Objective-C
2
star
20

HastyHare

Swift wrapper for RabbitMQ C client rabbitmq-c
Swift
2
star
21

swift-pg-extras

Commands providing shortcuts to common Postgres introspection queries (Swift port of heroku-pg-extras)
Swift
2
star
22

couchdb-migration

Python
2
star
23

homebrew-Hummingbird

Cask for Hummingbird
Ruby
2
star
24

debug-2227

Swift
1
star
25

Hourglass-Mobile

Objective-C
1
star
26

vapor-lockup-repro

Test project to reproduce a lockup in Vapor
Swift
1
star
27

daws-test

Test project for WebSocketActors
Swift
1
star
28

SASPopupButton

Objective-C
1
star
29

elme

Objective-C
1
star
30

Graf

Objective-C
1
star
31

MiteTime

Ruby
1
star
32

GrafServer

Python
1
star
33

Shooter

SpriteKit mini-game in swift (converted from Objective-C) with a Christmas theme
Swift
1
star
34

Sono

Sonography for iPad
Objective-C
1
star
35

Whiteboard

Objective-C
1
star
36

Tracker

Ruby
1
star
37

HeadPhoneJack

Swift
1
star
38

hummingbird-lockup-repro

Swift
1
star
39

swift-package-collection-model

Swift
1
star
40

Capio

Capacity Management Front-end
JavaScript
1
star
41

Sally

EK/VK Calculator
Objective-C
1
star
42

GrafWeb

Graf web front-end
JavaScript
1
star
43

Anjin

Sales rep application
Objective-C
1
star
44

builder-test-project

Test project for SPI builder
Swift
1
star
45

AbsReader

Objective-C
1
star
46

Hourglass

Objective-C
1
star
47

fs-html

A Swift DSL to generate HTML for use in server side swift projects - or anywhere you want to write type checked HTML.
Swift
1
star
48

LongRunningLazyInit

Objective-C
1
star
49

CouchStore2

Objective-C
1
star
50

Rester-sitemap

Swift script to create a restfile from sitemap.xml for use with Rester
Swift
1
star
51

jenkins-email-templates

1
star
52

dependencies-hang-repro

Swift
1
star
53

Persequor

Ruby
1
star