Hi, when working with multiple modules (libA, libB...
# multiplatform
j
Hi, when working with multiple modules (libA, libB) where libB depends on libA, how can I implement an interface or abstract class defined in libA in libB? The libA class or interface is renamed with the module name as a prefix making the child class / implementor not of the same type.
@ObjCName
doesn’t solve the problem. the libB doesn’t use the type from libA, it inherits from a completely different type
and if possible, i would like to use different modules, not a common umbrella with all the dependencies compiled in, so we can upgrade the different modules independently as long as we don’t make breaking changes
j
What problem are you facing exactly, can you share a code snippet & error message or so, please?
j
Copy code
LibA and LibB
LibB depends on LibA
LibA Defines interface EventBusEvent (Protocol) 

public interface EventBus {
   public interface Event 
}

__attribute__((swift_name("EventBusEvent")))
@protocol MEBEventBusEvent
@required
@end


LibB
Imports LibA
Defines class Event 

sealed class Event : EventBus.Event {   
   data object Initialized : Event()
   data class SessionStarted(val sessionUrl: String): DXAEvent()
}

__attribute__((swift_name("Event_busEventBusEvent")))
@protocol MyEventsEvent_busEventBusEvent
@required
@end

__attribute__((swift_name("Event")))
@interface MyEventsEvent : MyEventsBase <MyEventsEvent_busEventBusEvent>
@end


The resulting obj-c has pulled all of LibA into LibB but with different names, using the module name as a prefix.

So when passing an Event to a service defined in LibA the types do not match.
j
A workaround that comes to my mind might be to have the interface declared as protocol in objective-c (or swift, with the appropriate objective-c header generated from that), and import it both in libA and libB via cinterop - that shouldn't add any unwanted prefixes I think?
j
i’m not that familiar with the gradle configuration so I wouldn’t know where to start unfortunately to accomplish what your suggesting. I went with an umbrella solution now cause I could figure that out.
thanks for helping !
👍 1