0

Cannot get Xcode to generate the bridging file so it's currently empty and cannot find any guide/docs on what needs to be in the file. The empty bridging file is being imported in the .m where the class is needed. Swift file using @objcmembers on class definition.

How and what should go into the bridging file. Have looked for two days trying to make this work with no success.

Is there a way to turn back on the automatic generation of the bridging file in Xcode? Any docs on the contents of the bridging file?

2 Answers2

0

Don't confuse the two kinds of header. The "bridging header" is for Swift to see Objective-C code. It isn't relevant here.

The way Objective-C sees Swift code is through the generated interface header. You can see its name in your app target build settings:

enter image description here

So what that tells you is that if you #import "MomApp2-Swift.h" in your .m file, your Objective-C code will see your code that is exposed from Swift.

If you want to see what is in that generated interface header, then after you've done that import, Command-click on the file name.

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

To use a Swift class on objective-c you need to be sure that your class inherits from NSObject, has an @objc annotation on class definition and other elements that you want to use need to be marked with @objc. @objcmembers marks all elements visible from an Objc class located on file that imports the "project-Swift.h"

You may not need all class members visible from Objective-c