Quickly try a Swift library

Photo Credit: http://apple.com/swift/

Quickly try a Swift library

A new CocoaPods plugin called playgrounds allows you to quickly create a playground for a specific pod library. This helps to quickly get a feel for it before you drag another dependency in your iOS project.


First we need to install the plugin:

% gem install cocoapods-playgrounds
Fetching: cocoapods-playgrounds-0.0.2.gem (100%)
Successfully installed cocoapods-playgrounds-0.0.2

# make sure you've got a fresh pod version
% pod --version


Now let's try Scale, a unit conversion library for swift. First, we create our pod-specific playground:

% pod playgrounds Scale

This should open ScalePlayground in XCode. After building the Scale scheme, we can go ahead and open Scale/Scale.playground to try this shiny library!

//: Please build the scheme 'ScalePlayground' first
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true

import Scale

let length = 5.kilometer + 7.meter  // 5007 meter
let weight = 10.0.kilogram * 5.gram // 50000 gram

Happy playing!