Create and import swift framework

I’ve done with the following steps.

  1. Create a framework project, for example named “FooKit”. (Cocoa Touch Framework to be selected)
  2. Create a “.swift” file and add a public symbol, for example public func foo(), to it.
  3. Create an use-side (app) project. (I’ve chosen Single View Application)
  4. Open the root directory of “FooKit” by Finder, drag “FooKit.xcodeproj” there and drop it into the app project via Project Navigator.
  5. Add “FooKit” to Target Dependencies in the app’s Build Phases setting.
  6. Add “FooKit.framework” to Embedded Binaries in the app’s General setting.

Now you can build like this code in the use-side app.

import FooKit

func bar() {
    foo()
}

Leave a Comment