How to create a Swift framework to be used by an Objective C application

I am trying to create a Swift environment that can be used by an Objective C application.


  • Xcode 6.1, iOS 8

Basic steps:

Creating a Swift structure:

  • Create a new Swift iOS 8 environment
  • Create one Swift class that is public and inherits from NSObject
  • Declare one function, eg. func doSomething (text: String)
  • Creating a framework
  • Question: Where can I get the result? Derived data? Which folder? I tried to build a Release output by selecting Build for Profiling

Creating an Objective C Application:

  • Create a new Objective C application
  • Add the framework to your application project.
  • Question: How can I do this? It looks like nesting inline binary + linked structure should work. Is it correct?
  • Make sure Embedded Content with Hidden Code is set to Yes

Result: failure

Depending on how I create the framework and whether I am configured for a simulator or device, I either get a linker error like this:

Undefined symbols for x86_64 architecture: "_OBJC_CLASS _ $ __ TtC14BogusFramework9PublicApi" referenced by: objc-class-ref in AppDelegate.o ld: symbol not found for x86_64 architecture

... or...

I am getting a runtime error that it cannot find the Swift libraries:

dyld: library not loaded: @ rpath / libswiftCore.dylib Link from: /private/var/mobile/Containers/Bundle/Application/1B3E1AE0-05D5-4F3E-B866-FA2D46A17363/ Reason : image not found

I looked around a bit and found various options but none have worked so far.

Any help is appreciated.


source to share

All Articles