How Ansa Leverages Kotlin Multiplatform to Deliver Native SDKs for Android and iOS

Brandon McAnsh

November 8, 2024

At Ansa, we aim to create robust, versatile SDKs that extend our product’s accessibility across platforms, providing a consistent and seamless experience for developers and end-users alike.

Kotlin Multiplatform (KMP) has become an essential part of this mission, enabling us to write efficient, shared code that compiles into high-performance native binaries for both Android and iOS.

We’re thrilled to be early adopters of KMP, leveraging its potential to streamline mobile development across platforms without sacrificing native performance.

Why We Chose Kotlin Multiplatform

In evaluating cross-platform solutions, KMP stood out for its unique approach: it allows us to avoid duplicating core business logic while still delivering a truly native experience on each platform.

Unlike other cross-platform frameworks, KMP doesn’t aim to replace platform-native tools but works alongside them, enabling a more cohesive, native look-and-feel while minimizing code duplication.

With KMP, we can centralize core logic, enhancing development efficiency, simplifying maintenance, and ultimately providing a faster, more seamless experience for our partners. This approach allows our SDKs to fit naturally within each platform’s ecosystem, making it easier for developers to integrate our tools without a heavy framework overhead.

How Kotlin Multiplatform Works

Kotlin Multiplatform enables shared codebases across platforms without compromising native performance or unique platform experiences. At its core, KMP compiles Kotlin into platform-specific code: JVM for Android and LLVM for iOS, aligning with each platform’s native architecture.

This design allows us to achieve a smooth, responsive user experience that meets platform-specific performance expectations.

One of the most powerful features of KMP is its expect/actual declarations, which allow us to create shared code for core business logic while directly accessing platform APIs when needed. This lets us integrate native functionality precisely where required without fragmenting our codebase.

In short, KMP enables us to harness the power of Kotlin’s shared code model while ensuring that each platform’s native capabilities remain fully accessible.

Embracing New Technology

As an innovative and evolving tool, KMP has the potential to reshape mobile development. We’re excited to be part of this journey, joining companies like Netflix, Cash App, and VMware in adopting KMP for production use. For Ansa, investing in KMP not only accelerates our development process but also aligns us with a growing community working to build a unified mobile ecosystem.

While KMP technically supports Android, iOS, web, and desktop platforms, our primary focus for Ansa SDKs is on Android and iOS. By using KMP, we deliver an efficient, cohesive experience for our clients on both mobile platforms, all while keeping our codebase as streamlined as possible.

Building Ansa SDKs with AnsaShared

The core building block for our SDKs—AnsaCore and AnsaUI—is a KMP module we call AnsaShared. AnsaShared is structured into six inner modules, each with both internal implementations and public-facing APIs.

This modular design centralizes all shared logic, models, and core functionality, supporting multiple SDKs from a single structure. This modularity also allows us to scale our SDK functionalities easily and keep the code organized, efficient, and manageable.

AnsaCore and AnsaUI: Platform-Specific Adaptations

To deliver a seamless native experience, we wrap AnsaShared in thin, platform-specific wrappers called AnsaCore and AnsaUI for Android and iOS. On Android, AnsaUI is built in Kotlin using Jetpack Compose, while on iOS, AnsaUI is crafted in Swift with UIKit. These native wrappers ensure that our SDK feels intuitive for each platform, making it straightforward for developers to integrate Ansa’s tools into their applications.

Each wrapper adapts AnsaShared to meet platform-specific requirements, removing cross-platform challenges and creating a consistent, native experience for our partners. By combining shared logic with these thin, platform-tailored layers, we enable developers to work within familiar frameworks and avoid common cross-platform trade-offs.

Kotlin Multiplatform has transformed our SDK development process at Ansa, enabling us to build faster, integrate natively, and create high-performance tools that are intuitive for both Android and iOS developers.

If you’re considering cross-platform development for your next project, we encourage you to explore what KMP has to offer—like us, you may find it’s a game-changer in mobile SDK development.

External Article

We’re thrilled to be early adopters of KMP, leveraging its potential to streamline mobile development across platforms without sacrificing native performance.

Read Article Here

Ready to get started?

Connect With Us
Image of Benjamin Franklin as seen on the $100 bill

Ansa in the spotlight

Press, announcements, resources, and more