Skip to content

Swift

Add the package from its distribution repository, which tags each release with its version. It needs Swift 6.2 or later.

Package.swift
.package(
url: "https://github.com/maplibre/maplibre-native-ffi-distribution",
exact: "0.202611.0"
)

Then depend on its MaplibreNativeFFI product:

Package.swift
.product(name: "MaplibreNativeFFI", package: "maplibre-native-ffi-distribution")

The package uses your platform’s default backend. To choose another, enable the OpenGL or Vulkan trait:

Package.swift
.package(
url: "https://github.com/maplibre/maplibre-native-ffi-distribution",
exact: "0.202611.0",
traits: ["Vulkan"]
)

Initialize the library once per process, before you create a runtime, with the calling thread’s JNI environment and an Android Context:

main.swift
try initAndroid(
jniEnv: NativePointer(bitPattern: jniEnv),
context: NativePointer(bitPattern: context))