简体   繁体   中英

Swift interface for ObjC functions in static library for swift code in iOS-7

I have a static library, lets call it S - which is written in Objective-C. Now few people who support iOS-7 have started using Swift, as a result of which I have to give the interface to my functions also in Swift.

I know that we can use bridging headers to directly import Objective-C code into Swift (within same project), but how should I do it for my static library?

Also, I cannot have Swift files in my static library - as Swift is only supported by dynamic frameworks. So, if I make dynamic frameworks, I cannot then deploy this library for iOS-7.

The static library will become an integral part of the binary generated by the project linking to it. Therefore, including the headers of the static library in the bridging header should make its' functionality available from Swift code in that same project.

I figured it out. We need to make module.modulemap in the SDK (static library) and then the path to this module.modulemap needs to be added to Import Paths in Swift Compiler - Search Paths in Build Settings . Also, if the static library is being distributed via CocoaPods, podspec can be altered to do this setting automatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM