The plugin manifest
lecodes-plugin.json says what a platform needs to build the plugin in. It does not say what
the plugin does — that is the contract — nor where its code is: that is the
folders sdk/, ios/, android/ and web/.
lecodes plugin gen checks the manifest against the plugin's folders and reports every problem of
the file at once.
The whole shape
{
"id": "map",
"name": "Map",
"version": "2.0.0",
"sdk": "^2.0.0",
"description": "A vector map.",
"ios": {
"register": "LeCodesMapPlugin",
"packages": [{ "url": "https://github.com/maplibre/maplibre-gl-native-distribution", "exact": "6.29.0", "products": ["MapLibre"] }]
},
"android": {
"register": "io.letary.lecodes.plugins.map.LeCodesMapPlugin",
"dependencies": ["org.maplibre.gl:android-sdk-opengl:13.6.0"]
},
"web": {
"register": "web/map.ts",
"dependencies": { "maplibre-gl": "^6.7.0" },
"resources": {
"workerUrl": { "module": "maplibre-gl/dist/maplibre-gl-worker.mjs", "as": "worker-url" },
"css": { "module": "maplibre-gl/dist/maplibre-gl.css", "as": "text" }
}
}
}The keys every manifest has
| key | value |
|---|---|
id | the plugin's id: lower-case words joined by -. It must be the folder's name, and it is the key in an app's app.json |
name | a name for people |
version | the plugin's own version: 1.0.0 |
sdk | the SDK the plugin is written for, as a range of its version: ^2.0.0 |
description | optional |
ios, android, web | always present: an object where the plugin has a half, null where it has none |
A platform key that is missing is refused: "not supported" is said, not left out. A branch must
agree with the folders — an object needs its folder, and null with the folder present is an
error.
The ios branch
| key | value |
|---|---|
register | the Swift type with static func register(in: LeCodesEngine) |
module | the Swift module the half is built as. Default: LeCodes + the id in PascalCase |
infoPlist | keys of the app's Info.plist: a usage string, or a list (UIBackgroundModes) |
entitlements | entitlements the app needs |
packages | Swift packages the half links: { "url", "exact" or "from", "products": […] } |
binaries | prebuilt xcframeworks of the plugin, by their paths in it: ["binaries/ios/QrAnchorFFI.xcframework"] |
An xcframework stands beside the sources, never under ios/. Its folder's name is the name the
half links it by.
The android branch
| key | value |
|---|---|
register | the Kotlin object with fun register(engine: LecodesEngine, context: Context), by its full name |
module | the Gradle module the half is built as. Default: lecodes- + the id |
dependencies | Maven coordinates; a platform: prefix marks a BoM |
gradlePlugins | app-level Gradle plugins the shell applies (com.google.gms.google-services) |
<uses-permission>, services and receivers are the half's own
android/src/main/AndroidManifest.xml. So is a dependency whose minimum Android version is above
the app's: <uses-sdk tools:overrideLibrary="<its package>"/> there, with the half doing nothing
below that version.
The web branch
| key | value |
|---|---|
register | the module that exports register(host): a file of the web/ folder |
dependencies | npm packages the half imports, as in a package.json |
resources | files the half needs from its bundler, by the name it reads them under |
static | a folder of the plugin copied beside the built module as it is |
A resource is { "module", "as" }. module is a file of a dependency
(maplibre-gl/dist/maplibre-gl.css) or, starting with ./, a file of the plugin's own folder.
as is "text" (the file's text), "url" (its address) or "worker-url" (the address of a
script that stands alone, for a worker). The half receives them as the second argument of
register, and nothing is fetched before the half asks — so a half names no bundler.
A web half of a project's own plugin is built as plain TypeScript of its folder, with no packages. dependencies and resources are for a plugin built into the web host itself, as the first-party ones are. static is the way for a project's half to bring a library: a folder the half loads by its own address.
Declare a permission of your own: permissions
The contract tags a method with @permission <kind>. camera and microphone are built in; any
other kind is declared here, by name, with what it needs on each platform:
{
"permissions": {
"acme.bluetooth": {
"infoPlist": ["NSBluetoothAlwaysUsageDescription"],
"android": ["android.permission.BLUETOOTH_CONNECT", "android.permission.BLUETOOTH_SCAN"]
}
},
"ios": {
"register": "AcmeBluetoothPlugin",
"infoPlist": { "NSBluetoothAlwaysUsageDescription": "Connects to your Acme sensor." }
}
}| key | value |
|---|---|
infoPlist | the Info.plist keys whose usage strings the dialog shows. Each must have its text in ios.infoPlist |
android | the Android permissions the kind stands for. Each must be a <uses-permission> of the half's manifest |
androidAnyOf | true when one of those granted is the kind granted (location: fine or coarse) |
androidFeatures | hardware features those permissions imply. Each must be declared android:required="false", or the store hides the app from devices without the hardware |
lecodes plugin gen holds the plugin to its declaration and refuses a manifest that lacks a usage
string or a <uses-permission>. A kind is named in camelCase with your vendor's prefix.
On Android the generated code asks for the permissions itself. On iOS the code that asks belongs
to the framework the plugin links, so the generated register takes one asker per kind:
XChannel.register(in: engine, acmeBluetooth: PermissionAsker(…)) { … }.
A half folder: implement a first-party plugin for one platform
{
"id": "ar-8thwall",
"name": "AR on 8th Wall",
"version": "1.0.0",
"sdk": "^2.0.0",
"implements": "ar",
"ios": null,
"android": null,
"web": { "register": "web/ar-8thwall.ts", "static": "xr-runtime" }
}implements names the first-party plugin whose contract the folder implements. The folder has no
contract.d.ts and no sdk/: the app's side stays the SDK's. app.json names the folder for the
platforms it covers — "ar": { "web": "./plugins/ar-8thwall" } — and the first-party halves stay
everywhere else. When the half's register returns false, the first-party half takes over on
that page.
Keys that are gone
A manifest written for the 1.x plugins is refused with the reason: provides and js (the
contract and the sdk/ folder say that now), sources and minSdk in a platform branch, and a
desktop branch — desktop plugins are a separate system with a manifest of
their own.
Next
- Write a native plugin — the walk through a whole plugin
- The plugin contract — the other file you write