Import an Objective-c structure into a Swift framework project

I am creating a framework in which I need to import some objective-c frameworks, now I need to import "Beaconstac.framework", but since we cannot add the bridge title in the quick development project, so my question is how can I use this structure in my project, it is not available right in my project that I tried

import beaconstac

but his error message "There is no such module"

Is there an alternative for this?

+13
objective-c swift ibeacon beacon
source share
3 answers

You need to import the Beaconstac framework into your umbrella header. That is, if you usually used, for example, #import <Beaconstac/Beaconstac.h> in the header of the Obj-C bridge, for the framework you need to put it in the header of the umbrella.

For more information, see this chapter in the Apple documentation:

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-ID130

+4
source share

Steps to incorporate an existing Obj C environment into a fast platform project

Let's say we create a SwiftProj.framework project in swift that internally must use Objective-C "ObjC.framework"

  1. Place ObjC.framework in the Frameworks folder, create a Link to Swift project through Linked Frameworks and libraries, and create the module.modulemap file at the same level.
  2. In module.modulemap
 module ObjC{ header "ObjC.framework/Headers/ClassA.h" export * } 
  1. Create an xcconfig file (File-> Create → iOS-> Other-> Configuration Settings File)

  2. In xcconfig file

 SWIFT_INCLUDE_PATHS = $(SRCROOT)/ MODULEMAP_PRIVATE_FILE = $(SRCROOT)/module.modulemap 

Now you can access ObjC.ClassA in SwiftProj.framework

+14
source share

Create a file called module.modulemap and include the following contents:

 module ObjCFrameworkName { header "ObjCFrameworkName.framework/Headers/ObjCFrameworkNameUmbrellaHeader.h" export * } 

Remember that you need the correct path to the Obj-C probe header, which may be slightly different from what is shown in the example above.

If you are still stuck, I highly recommend taking a look at this project .

+2
source share

All Articles