If you want to modulate your Swift code, you must use modules!
Creating a new module is quite simple.
Add a new goal to your project by clicking the plus sign here:

Select "Framework and Library" for the appropriate platform (iOS / OS X):

Select "Cocoa Framework" (or Cocoa Touch, platform dependent) and click "Next":

Give your module a name and change the language to Swift (or leave it as Objective-C, it does not matter, you can use both).

Add to your Swift file:

Add the code to your Swift file. Please note: the default access level for Swift is internal , which means that it can be accessed from anywhere in the module, but not from outside the module. Any code that we want to use outside the module must have a public access level.
public class ModularSwift { public init(){} public var foo: Int = 0 }
Be sure to create your module (Cmd + B):

Return to the original goal, import the module and start using its code:
import MyModularSwiftCode let foo = ModularSwift()
Xcode is completely happy:

Now comment out the import statement and notice the errors:

nhgrif
source share