Calimari328 Calimari328 - 1 year ago 124
Swift Question

Xcode playgrounds can't access swift files in Sources folder

I just upgraded to Xcode 6.3 and they offered something new to the Playgrounds. If you make a new playgrounds and you open the project navigator, you will see a Sources folder and inside that there is a "SupportCode.swift" file. At the top of that file it reads

This file (and all other Swift source files in the Sources directory
of this playground) will be precompiled into a framework which is
automatically made available to <PLAYGROUND_NAME>.playground.

I tried putting a function in to there and it is not available to my playground. What am I doing wrong? Do I have to manually compile the SupportCode.swift file manually? How?

Answer Source

You have to add public access attribute to your classes, methods and properties in source folder to make them accessible from main playground file as they treated as separate module by compiler

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download