Skip to content

Instantly share code, notes, and snippets.

@marcboquet
Created August 8, 2014 15:37
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcboquet/340c240c50aed6c71a1e to your computer and use it in GitHub Desktop.
Save marcboquet/340c240c50aed6c71a1e to your computer and use it in GitHub Desktop.
Create empty Swift playground files
#! /usr/bin/ruby
require 'pathname'
platform = "iphonesimulator" # or "macosx"
contents_xcplayground = <<XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='1.0' sdk='#{platform}'>
<sections>
<code source-file-name='section-1.swift'/>
</sections>
</playground>
XML
time = Time.now.strftime "%Y%m%d-%H%M%S"
path = Pathname.new "/tmp/playgrounder/#{time}.playground"
path.rmtree if path.exist?
path.mkpath
File.open(path+"contents.xcplayground", 'w') {|f| f.write(contents_xcplayground) }
`open #{path}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment