Importing Swift to Objective-C, Multiple Modules

This goes by Module (i.e., target), not by project (ignore the confusion on the Internet).

So in my MIDI Designer project, which includes several targets, we change the generated name for all the modules, stored in the Objective-C Generated Interface Header Name property, from

$(SWIFT_MODULE_NAME)-Swift.h

to

MidiDesignerAllTargets-Swift.h




Then in each Objective-C class, you can import directly in the .m like this:

#import "MidiDesignerAllTargets-Swift.h"

Make sure to keep the name of your global import handy!

Dynamic Instantiation of Swift Classes and Interface Builder

Most of the time, it's enough for a Swift class to inherit NSObject to be able to be used from Objective-C.

For dynamic instantiation and, more importantly, use in Interface Builder, you need to specify the class' name explicitly using @objc. For example:

@objc(SliderV2)
class SliderV2: Slider {


Additional Notes
You can't see the header at all? It's not being generated? This answer has your back. Basically you need to:
  • Define a Product Module Name (no spaces) for the Project
  • Set Defines Module must be set to Yes in Build Settings, under Packaging

In Xcode 8, the Objective-C Generated Interface Header Name will be under Swift Compiler, General. Same same.