Anthony Pages
05/04/2021, 2:01 PM//KMPlibAPI.h
@protocol KMPAPIFoo
@required
- (void)bar __attribute__((swift_name("bar()")));
@end;
//KMPlib.h
@protocol KAFoo // <----- here we have a redefinition of the protocol.
@required
- (void)bar __attribute__((swift_name("bar()")));
@end;
@interface Baz
- (void)injectFoo:(KAFoo)foo __attribute__((swift_name("injectFoo(foo:)"))); // <----- and here we are using it, instead of using KMPAPIFoo
@end;
I've tried to put the dependencies in compileOnly
into gradle, but nothing changed.
Anyone is confortable with gradle compilation option for Kotlin native and dependencies ?louiscad
05/04/2021, 5:21 PMcompileOnly
isn't supported in Kotlin/Native.
The solution is to set the visibility of implementation details to internal
Anthony Pages
05/05/2021, 8:19 AMimport KMPlibAPI
public class SampleFoo: NSObject, Foo {
func bar() { }
}
and into the app
import KMPlib
import MySwiftPackage
let foo = SampleFoo()
let baz = Baz()
baz.injectFoo(foo)
As you can see, I can't set injectFoo
to internal
here, otherwise I won't be able to call it through the iOS app.
I'm not sure if I made it clear ?louiscad
05/05/2021, 8:23 AMinjectFoo
internal, but make the rest internal
?Anthony Pages
05/05/2021, 8:24 AMbaz
class ?louiscad
05/05/2021, 8:25 AMAnthony Pages
05/05/2021, 8:27 AMinjectFoo(foo:Foo)
into the KMPlib, it will include the Foo protocol into the KMPlib.h
and that's my point, I don't want to have the protocol exposed in the KMPlib.h but have a reference to the KMPlibAPI.h (which contain the Foo
protocol)louiscad
05/05/2021, 8:29 AMAnthony Pages
05/05/2021, 8:30 AMlouiscad
05/05/2021, 8:32 AMAnthony Pages
05/05/2021, 8:41 AM// API project
public interface Foo
// libA project
public class Bar {
fun doSomething(foo: Foo)
}
// libB project
import API
public class FooImpl: Foo { }
// android app
import libA
import libB
var foo = FooImpl()
var bar = Bar()
bar.doSomething(foo) // <----- Everything is fine here
but in iOS I can't:
// ios app
import libA
import libB
var foo = FooImpl()
var bar = Bar()
bar.doSomething(foo) // <----- Error here : FooImpl is of type APIFoo but here LibAAPIFoo is excpected
because I have the folowing headers :
/// API.h
@protocol APIFoo
// libA.h
@protocol LibAAPIFoo
@interface Bar
- (void)injectFoo:(LibAAPIFoo)foo
@end;
louiscad
05/05/2021, 8:49 AMAnthony Pages
05/05/2021, 8:51 AMlouiscad
05/05/2021, 8:52 AMAnthony Pages
05/05/2021, 8:56 AM