realm-kotlin icon indicating copy to clipboard operation
realm-kotlin copied to clipboard

Internal refactor: Better support separate base and sync builds

Open cmelchior opened this issue 3 years ago • 1 comments

From https://github.com/realm/realm-kotlin/issues/713

(Christian) We need to figure out how to split cinterop so it supports both base and sync builds. Instead of right now where sync native code is getting shipped with the base library. The networking refactor in Core should in theory remove the need to depend on us shipping SSL, but it is unclear what their timeline is.

  • Claus has some ideas on this.
  • We should try to avoid leaking internal implementations. Our different modules cause symbols to leak into the public interface.
  • How far is Core with unified networking?
  • Need to re-evaluate the hierarchical layout.

From @rorbech According to my initial investigations (more that a year ago 🙈) it should be possible to achieve a concept like build variants through custom compilations: https://kotlinlang.org/docs/multiplatform-configure-compilations.html

With the current setup (different modules for library-base and library-sync) it should also be possible to configure that library-base-dependency of library-sync to override the cinterop-dependency to such a new cinterop-sync variant.

Maybe worth to re-investigate if there is a formal KMP-variant concept on its way.

cmelchior avatar Mar 15 '22 10:03 cmelchior

More input:

I have been trying to add support for Realm.syncSession() and is running into all the same problems we had in Java.

Realm.syncSession cannot have a backing field, so in order to cache it we need some wrapper. In Java, we had ObjectServerFacade, which was selected using reflection. This is both annoying to set up, but also annoying to maintain.

So in order to avoid having to add too many hacks to give Sync API's access to internal Realm API's, it feels saner to just figure out how to make this happen.

Perhaps it would be easier to just start by combining library-base and library-sync and then tackle cinterop later? 🤔

cmelchior avatar Mar 27 '22 16:03 cmelchior