:eyes: KMP Classes not visible in Swift by default...
# ios
m
👀 KMP Classes not visible in Swift by default 👀 Sometimes I face the issue that classes defined in KMP shared code are not visible in Swift. I work around this issue by adding a “fake usage” to the
MainViewController.kt
class like below. Afterwards I can access
IOSPlatformFile
in Swift code.
Copy code
fun MainViewController() = ComposeUIViewController { App() }

// so swift code can access this
val platformFile: IOSPlatformFile = IOSPlatformFile("")
Could someone clarify what I’m doing wrong in these cases? Are only classes from the main module visible to Swift by default?
âś… 1
f
Hi, Yes, only the main module (the one built in a iOS framework) is visible. You can extend that by using export gradle keyword
For example: on my playground, I need to export some library, even some kotlin methods
đź‘€ 1
Also, control what you put inside the bridge. Too much (and useless) content inside is not good practise
🙏 1
m
Thanks @François for clarifying! That makes sense