Skip to content

Maui.NativeLibraryInterop is a community-created library of binding samples to help .NET MAUI developers interop with native libraries more easily

License

Notifications You must be signed in to change notification settings

CommunityToolkit/Maui.NativeLibraryInterop

Repository files navigation

Native Library Interop for .NET MAUI

Native Library Interop, formerly referred to as "Slim Bindings", refers to a pattern for accessing native SDKs in .NET MAUI apps, including .NET for Android, .NET for iOS, and .NET for Mac Catalyst apps. This repository provides a starting point for developers looking to get started with creating new bindings or consuming existing bindings constructed via Native Library Interop.

Native Library Interop Binding overview

All Native Library Interop bindings and samples are contributed by you, our amazing .NET community, and maintained by a core set of maintainers.

Documentation

docs

All of the documentation for CommunityToolkit.Maui.NativeLibraryInterop can be found here on Microsoft Learn:

https://learn.microsoft.com/dotnet/communitytoolkit/maui/native-library-interop

Getting Started

Quick Start: New binding

Create your own binding via native library interop by copying the contents of template and following the getting started instructions in the documentation.

Quick Start: Facebook, Firebase, Google Cast samples

The samples direcotry in this repo contains sample MaciOS and/or Android bindings for and sample .NET MAUI apps consuming specific libraries. Get started with Native Library Interop using the Facebook, Firebase Analytics, Firebase Messaging, and Google Cast samples in this repository:

  1. Submodule or clone this repo

  2. Navigate to the appropriate directory for the binding you're interested in using or building from, and read the README in the relevant directory for instructions on how to build and configure in your .NET app. Make modifications as you wish.
    e.g. To leverage Firebase Messaging APIs on your .NET MAUI, .NET for iOS, and .NET for Mac Catalyst apps, navigate to samples/firebase/macios/Firebase.MaciOS.Binding.

  3. Add a project reference to your MAUI app pointing to the path where you have cloned the repo
    e.g. For Firebase Messaging, add to your csproj:

    <ProjectReference Include="<YourPathToClonedRepo>\samples\Firebase.MaciOS.Binding\Firebase.MaciOS.Binding.csproj" />

    OR build the binding projects and consume the .dll assembly artifacts.

  4. Use the binding in your .NET app! See sample usage in the Sample .NET MAUI apps included in each of the relevant directories.

For more information and guidance, check out the documentation.

Contributing

There are two main ways in which you might consider contributing to this project:

  • Expanding API Surface for existing bindings: If you are interested in modifying an existing binding in this repository by expanding its API surface and exposing more functionality that would benefit the majority of developers, you are welcome to open a pull request.
  • Adding new bindings: If you are interested in sharing with the community a binding you have created for a library that is not already in this repository, you are welcome to open a pull request.

Please keep in mind that for a contribution to be considered, it:

  • Must be broadly applicable and beneficial to a wide audience of .NET developers (e.g., an internal company's native SDK would not be a good candidate)
  • Must align with this repository's existing structure and conventions
  • May require some collaboration with maintainers to refine the API surface changes

Resources

Code of Conduct

As a part of the .NET Foundation, we have adopted the .NET Foundation Code of Conduct. Please familiarize yourself with that before participating with this repository. Thanks!

.NET Foundation

This project is supported by the .NET Foundation.