Hello guys. I have a pure Swift framework that I w...
# kotlin-native
d
Hello guys. I have a pure Swift framework that I want to use from a Kotlin MPP. In order to be able to use the framework I had to create [this bridging class](https://gist.github.com/dfpalomar/0322a839ba2bd4b5959be3ca9d58c3eb#file-cryptobridge-swift) and annotate the class and methods with
@objc
. I updated my build.gradle file to add the
cinterops
configuration and the problem is that when I try to build the project I get the following error:
Copy code
> Task :p2p-common:cinteropCryptoCocoaIOS FAILED
Exception in thread "main" java.lang.Error: CryptoCocoa.framework/Headers/CryptoCocoa-Swift.h:203:4: error: expected a type
[
CryptoCocoa-Swift.h
](https://gist.github.com/dfpalomar/0322a839ba2bd4b5959be3ca9d58c3eb#gistcomment-2837982) is a file generated by Xcode. The line 203 is
- (NSData * _Nonnull)generateAESKeyWithKeySize:(NSInteger)keySize SWIFT_WARN_UNUSED_RESULT;
Am I using an unsupported swift feature? Any idea about how can I sort this out?
s
Hello. The generated header is a bit incorrect: if you import this header to Objective-C source file, it won’t compile too. The reason is that generated Swift header lacks Foundation import. To workaround this, please add
Foundation/Foundation.h
as first entry of the
headers
list, i.e.
Copy code
headers = Foundation/Foundation.h MyUtils-Swift.h
❤️ 1
d
Thanks a lot @svyatoslav.scherbina. That fix my problem