This toolkit allows you to combine MAUI with Kotlin Multiplatform (KMP) by generating bindings for iOS and Android from Kotlin common code.
Currently the following features are supported:
- Generate iOS Maui bindings ApiDefinitions.cs file based on annotated kotlin source code
- Generate android csproj file android binding project
- Generate android fat aar via gradle plugin
- Configurable namespace and prefix for C# binding generation
You can configure the namespace and prefix used for generated C# bindings by adding KSP arguments in your build.gradle.kts:
ksp {
arg("maui.kmp.csharp.ios.namespace", "YourNamespace")
arg("maui.kmp.csharp.ios.frameworkPrefix", "YourPrefix")
}Parameters:
maui.kmp.csharp.ios.namespace: The namespace for generated C# bindings (required)maui.kmp.csharp.ios.frameworkPrefix: The name of the framework generated by kotlin (required)
Example:
ksp {
arg("maui.kmp.csharp.ios.namespace", "MyCompany.Mobile")
arg("maui.kmp.csharp.ios.frameworkPrefix", "Native")
}This will generate C# bindings like:
namespace MyCompany.Mobile
{
interface NativeBase : ObjCRuntime.INativeObject
{
// ...
}
}The gradle plugin uses https://github.com/aasitnikov/fat-aar-android to generate fat aar file. You need to add the following to your buildscript repositories:
maven {
setUrl("https://jitpack.io")
content {
includeGroup("com.github.aasitnikov")
}
}