Closed kermankohli closed 9 years ago
To use the plugin for Swift you should create one single Objective-C bridging header and add #import <OneSkyOTAPlugin/OneSkyOTAPlugin.h>
along with other Objective-C imports there.
Please read the documentation for more details.
I would assume that a SDK for a product would provide Swift support by default?
You can mix and match Swift and Objective-C in the same project, one simply won't write a library in Objective-C and rewrite it in Swift, vice versa.
If you develop in Swift you can not avoid using libraries written in Objective-C, so please read the documentation and learn how to use the bridging header.
The bridging header should be created for the project and includes ALL Objective-C files and libraries, not just one library.
Even if a header was provided you still need to configure the Build Settings to make it work, you can't declare multiple bridging headers in Build Settings so what you are asking simply doesn't make sense for a library written in Objective-C.
Usually the name of the bridging header includes the name of the project. This step is expected to be done by the project owner.
You can find more detail here: http://stackoverflow.com/a/24005242
Another thing, OSLocalizedString doesn't work in Swift because of the #define in Objective-C
@bretdabaker Sorry, got a bit confused (it's 2am here)!
It's okay, let me add swift integration guide to README.md later. Will also checkout the macro.
Thanks! I really need the plugin soon though :p
You can still use the plugin without the macro.
OneSkyOTAPlugin.localizedStringForKey("key", value: "value", table: "tableName")
Is there a macro without the table property and comment instead of "value"?
OneSkyOTAPlugin.localizedStringForKey("key", comment: "value")
You can use public functions to wrap the code, here is the file with the macros:
Swift 3 needs to be like this:
public func OSLocalizedString(_ key: String, comment: String) -> String {
return OneSkyOTAPlugin.localizedString(forKey: key, value: "", table: nil)
}
public func OSLocalizedStringFromTable(_ key: String, table: String, comment: String) -> String {
return OneSkyOTAPlugin.localizedString(forKey: key, value: "", table: table)
}
I can't use this library on Swift because it says that the OneSkyOTAPlugin module can't be found - presumably because there's no bridging headers.