1

I know this question was asked before, but I didn't find an answer in relation to Xcode 7 and Swift 2. Many answers are just ambiguous, incorrect or outdated.

Is there a clear way to import a single class or a set of classes to a playground?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335

1 Answers1

5

In the Playground go to menu

View / Navigators / Show Project Navigator

and copy your class files into the Sources folder.

Your classes have to be marked public like this:

public class MyPlayGround {
    public class func sayHello() {
        print("Hello")
    }
}

The Playground will then have access to the classes:

MyPlayGround.sayHello()
Eric Aya
  • 69,473
  • 35
  • 181
  • 253