I'm trying to use my (swift library with @objc) fr...
# multiplatform
v
I'm trying to use my (swift library with @objc) from iosMain using cinterop. my library depends on CoreBluetooth. When i run ./gradlew shared:cinteropMyProjIosArm64 task, i get the following error: cannot find protocol declaration for 'CBPeripheralDelegate' My def file:
Copy code
package = MyKit
language = Objective-C
modules = MyKit
linkerOpts = -framework CoreBluetooth -framework Foundation 
depends = Foundation CoreBluetooth
I've found that MyKit-Swift.h file has the following block:
Copy code
#if defined(__OBJC__)
#if __has_feature(objc_modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import CoreBluetooth;
@import Foundation;
@import ObjectiveC;
#else
#error ("No imports for you :(") //<------------- I've added this line, and now, this is the error message.
#endif
Please help :)
Ok, I've added "-fmodules" to my compiler options, and that fixed this problem.