XMPP (Smack) lib support in multiplatform

we’ve crafted a robust Chat feature within native Android and iOS projects, using the powerful Smack library for functionality. As we incorporate this feature using KMM into our Android/iOS application through Kotlin Multiplatform Mobile (KMM) shared modules, we encounter a roadblock: Smack is not currently compatible with KMM. Are there any forthcoming plans to extend support for the integration of Smack with KMM?

I have added the below smack lib in the KMM shared gradle file but classes of Smack is not accessible in commonMain code but same Smack class is accessible in AndroidMain

val smack = “4.3.4”


Can any one please help?

The incompatibility of Smack with Kotlin Multiplatform Mobile (KMM) can indeed pose challenges when integrating it into shared modules. As of my last update, Smack does not officially support KMM, which explains why you’re encountering issues accessing Smack classes in the commonMain code.

However, there might be a few potential workarounds or solutions you can explore:

  • Use Platform-Specific Code: Since you mentioned that Smack classes are accessible in AndroidMain but not in commonMain, you can consider implementing the chat feature separately for Android and iOS using platform-specific code. This means you’ll have separate implementations for Android and iOS using Kotlin for Android and Swift for iOS.

  • Create Wrapper Classes: If you still want to utilize Smack in your shared module, you can create wrapper classes around the Smack functionality. These wrapper classes can provide a common interface for interacting with Smack, and the actual implementation details can be platform-specific. This approach allows you to keep most of your chat logic in the shared module while dealing with platform-specific details in platform-specific code.

  • Explore Alternatives: While Smack is a popular choice for XMPP-based chat applications, you might also explore other libraries that are compatible with KMM. Look for libraries or SDKs that provide cross-platform support and are compatible with Kotlin Multiplatform.

  • Community Contributions: Keep an eye on the Smack library’s development and community contributions. Sometimes, compatibility with new platforms or frameworks is added through community contributions or library updates. You can also consider contributing to the Smack library yourself to add support for KMM if feasible.

  • Reach Out to Smack Developers: Contact the developers or maintainers of the Smack library to inquire about their plans for KMM compatibility. Expressing your interest and sharing your use case might influence future developments or prompt discussions within the Smack community about adding KMM support.

In summary, while Smack may not currently support Kotlin Multiplatform Mobile out of the box, there are potential workarounds and avenues to explore. Evaluate the trade-offs between different approaches based on your project requirements and constraints.