Skip to content

voize-gmbh/maui-kmp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maui-kmp

This toolkit allows you to combine MAUI with Kotlin Multiplatform (KMP) by generating bindings for iOS and Android from Kotlin common code.

Features

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

Configuration

C# Binding Namespace Configuration

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
    {
        // ...
    }
}

Setup

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")
    }
}

About

Combine MAUI with Kotlin Multiplatform (KMP)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors