Migrating existing mobile library project to KMM

I have an existing Kotlin Android and Swift iOS projects.
I would like to gradually migrate these projects to Kotlin Multiplatform.
In order to do that, I moved some of the internal logic of the Android project into a common source set.
Now, I would like the Swift project to start using this logic but the problem is that the visibility of all this logic is internal ant therefore it doesn’t get packaged inside the iOS framework produced by the KMM project and can’t be used in Swift.
If I make it public, it is available to Swift but also becomes part of the Android API and I don’t want that.
What would be your recommended way to share internal logic between Android and existing Swift code?

Can you clarify more why you don’t want the logic to be accessible from your android project but still want it to be common?

If you want something to only be accessible in iOS i think you should put it in the iOS module.

Or if your common code depends on uncommon structures you might use expect declarations

Additionally you might take advantage of @OptionalExpectation if your expect declarations only applicable in iOS

To clarify, I do want it to be accessible to the Android as internal. This is a library project and therefore anything public becomes a part of the API and I don’t want that.

If you want it to be internal in android and public in iOS you might make the declaration in the common module internal and have a public delegate in iOS or vice versa.

If you want it to be internal in both but still accessible you might instead rely on the package naming convention (for example com.example.internal). Normally, people won’t use library code that is in a private package.
Additionally, you might add an OptIn requirement on the internal components so nobody use it even by mistake

I do want them to be internal in Android and public in iOS.
The firs solution you propose is probably the proper one but it means duplicating the APIs of hundreds of classes and then maintaining these duplicates. It will make the transition much harder and longer and maybe even not worth it :face_with_diagonal_mouth:.
The OptIn option sounds like a viable solution but it’s still a workaround rather than a real solution.
Thanks a lot @LSafer for your help :slightly_smiling_face:!