Import Objective-c framework into Swift framework project

后端 未结 3 370
故里飘歌
故里飘歌 2020-12-30 05:03

I am building a framework in which I need to import some objective-c frameworks for now I need to import \"Beaconstac.framework\" but as we can not add a bridging header in

3条回答
  •  悲&欢浪女
    2020-12-30 05:43

    Steps to include an existing Obj C framework in a swift framework project

    Say we are creating an “SwiftProj.framework" project in swift which internally has to use an Objective C “ObjC.framework”

    1. Place the ObjC.framework in Frameworks folder, Link to Swift framework project via Linked Frameworks and Libraries, and create a module.modulemap file at the same level.
    2. In module.modulemap
    module ObjC{
        header "ObjC.framework/Headers/ClassA.h"
        export *
    }
    
    1. Create xcconfig file (File->New->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

提交回复
热议问题