Native apps (iOS & Android)
Diadem can be wrapped as a native Android and iOS app using Capacitor. The native app bundles the Diadem client and runs it in a system webview as a thin client: every request is sent to a remote Diadem instance.
Two flavours are possible from the same codebase:
- Generic app: on first launch the user is asked for the URL of the Diadem instance to connect to (the instance gate). They can change it later under Profile → Instance. This is meant for public builds that are hosted on app stores and the likes.
- Branded app: an instance URL is baked in at build time, so the gate and the instance switcher are hidden and the app always connects to that one instance. This is meant for when you want to build native Diadem yourself.
The map still renders with MapLibre GL JS inside the webview. (Native MapLibre rendering is not used.)
Requirements
Section titled “Requirements”- Everything from the normal installation (Node 24+, pnpm)
- JDK 21 and the Android SDK (Capacitor 7 builds against Java 21)
- A connected Android device with USB debugging, or an emulator
- iOS 16.4+ only: a Mac with Xcode 26+, CocoaPods, and an Apple Developer account for App Store/TestFlight uploads
On macOS, make sure the full Xcode install is selected, not only the Command Line Tools:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developerxcodebuild -versionpod --versionA dev shell with the full Android toolchain (Node, JDK 21, Android SDK, Gradle)
is provided in flake.nix. Run native build commands inside it:
nix developOn other systems, install JDK 21 + the Android SDK yourself and set
ANDROID_HOME/JAVA_HOME.
How a native build works
Section titled “How a native build works”pnpm run build:native -> static client in build/pnpm run build:native:android -> build client and sync android/pnpm run build:native:ios -> build client and sync ios/After syncing, build the native project with Gradle, Xcode, or Capacitor.
The native build command first syncs the shared TypeScript configuration in
.svelte-kit/, so it also works on a fresh checkout. Native compilation then uses
.svelte-kit-native/, keeping its generated runtime files separate from a running
web development server. Both production web and native builds still write their
final output to build/; run those builds one at a time.
Development builds
Section titled “Development builds”Build a debug APK and run it on a connected device.
-
Confirm the device is connected and enter the nix shell (if on NixOS):
Terminal window adb devicesnix develop -
Build the client and sync the Android platform:
Terminal window pnpm run build:native:android -
Build, install, and launch the debug APK:
Terminal window npx cap run androidOr build the APK manually and install it:
Terminal window cd android && ./gradlew assembleDebugadb install -r app/build/outputs/apk/debug/app-debug.apkadb shell am start -n ee.malt.diadem.debug/ee.malt.diadem.MainActivity
After changing client code, re-run pnpm run build:native:android before rebuilding.
Debug builds install as Diadem Debug (ee.malt.diadem.debug), so they can run
alongside the release app without replacing its saved instance or session.
iOS simulator builds
Section titled “iOS simulator builds”Build and run the app on an iOS simulator from a Mac with Xcode installed.
-
Build the client and sync the iOS platform:
Terminal window pnpm run build:native:ios -
Open the workspace in Xcode and run the App scheme on an iOS simulator:
Terminal window npx cap open ios -
Or build from the CLI against an installed simulator runtime:
Terminal window xcrun simctl list devices availablexcodebuild -workspace ios/App/App.xcworkspace \-scheme App \-configuration Debug \-destination 'platform=iOS Simulator,name=iPhone 15 Pro' \build
After changing client code, re-run pnpm run build:native:ios before rebuilding.
Test iOS deep links in the booted simulator with:
xcrun simctl openurl booted "diadem://pokemon/<id>"Testing deep links and auth
Section titled “Testing deep links and auth”-
Deep links use the
diadem://scheme. Simulate one with:Terminal window adb shell am start -a android.intent.action.VIEW -d "diadem://pokemon/<id>" -p ee.malt.diadem.debug -
Discord/OAuth login opens the system browser and returns to the app via
diadem://auth. The server offers a Return to Diadem button if the browser blocks the automatic return. Bearer credentials stay bound to the selected instance, including across restarts.
Update the Diadem server alongside the app when rolling out native auth fixes.
Login handoff codes use the existing internal verification table, so the
browser callback and app exchange can reach different server workers. No new
database migration is required for an existing Better Auth installation. Finish
the rollout across all workers before testing; mixing old in-memory handoff
workers with updated workers can still fail intermittently.
To test cross-worker handoff and concurrent single-use exchanges against MySQL:
pnpm test src/lib/server/auth/nativeHandoff.mysql.test.tsThe suite creates and drops its own temporary database, so the account needs database creation privileges. Without this variable, the MySQL tests are skipped.
Testing mobile layouts and the keyboard
Section titled “Testing mobile layouts and the keyboard”Run these checks on a real device before publishing a release. Include portrait and landscape, the device’s larger text setting, and both gesture and three-button navigation where available:
- On the instance picker, open the keyboard, enter an instance URL, and verify that the input, connection result, and Connect button remain reachable by scrolling. Close the keyboard and confirm the screen returns to its full height.
- Open search and a filter editor with the keyboard visible. The search field, results, editor actions, and close buttons must remain reachable without scrolling the map behind them.
- Expand and collapse the Filters, Profile, and Tools drawers, then open a map object’s popup. Check that titles and close/share buttons fit, popup content scrolls, and bottom actions stay above the navigation bar.
- Rotate with a drawer or dialog open, then repeat after closing the keyboard. Drawer snap points should adjust to the new height without leaving a blank gap or placing controls outside the viewport.
- Check an unreachable instance and a long instance name. Retry and disconnect actions must remain visible and text must wrap within the screen.
On Android 15 and newer, MainActivity keeps the WebView clear of side display
cutouts. The map draws behind the transparent status and navigation bars; their
safe areas and keyboard insets pass through to the WebView so controls remain
clear. Earlier Android versions keep the status bar outside the WebView. iOS uses
CSS safe-area insets. Avoid adding the same system-bar padding in both native code
and CSS.
Native overlays follow the visual viewport so the keyboard can reduce their
available height without hiding controls.
Also smoke-test the web build in a narrow mobile browser and on desktop after changing shared drawer or dialog components.
Production builds
Section titled “Production builds”Android (Google Play)
Section titled “Android (Google Play)”Play requires a signed App Bundle (.aab).
-
Create a keystore (once) and keep it safe:
Terminal window keytool -genkey -v -keystore diadem.keystore -alias diadem \-keyalg RSA -keysize 2048 -validity 10000 -
Tell Gradle how to sign by creating
android/keystore.properties(do not commit it):storeFile=/absolute/path/to/diadem.keystorestorePassword=...keyAlias=diademkeyPassword=...and wiring it into
android/app/build.gradle(signingConfigs+buildTypes.release.signingConfig) per the Capacitor signing docs. -
Build the release bundle:
Terminal window pnpm run build:native:androidcd android && ./gradlew bundleRelease# -> android/app/build/outputs/bundle/release/app-release.aab
Upload the .aab to the Play Console.
Retry Google Play only
Section titled “Retry Google Play only”To retry a failed Play upload, open Actions → Google Play → Run workflow in
GitHub. Select the branch containing the fix (typically main) and the desired
play_track (internal, alpha, beta, or production).
This workflow rebuilds and uploads the version already recorded in
android/app/build.gradle, using its matching changelog from
fastlane/metadata/android/en-US/changelogs/. It uses the same ANDROID_* signing
secrets and PLAY_SERVICE_ACCOUNT_JSON as the full Release workflow.
Use this for a version code whose Play upload failed. Google Play requires a new version code after a successful upload; use the full Release workflow for a new version.
iOS (App Store)
Section titled “iOS (App Store)”On a Mac:
pnpm run build:native:iosnpx cap open ios # opens XcodeSet the signing team and bundle id in Xcode, then Archive and upload to App
Store Connect. The committed project registers the diadem:// URL scheme for
OAuth/deep links and includes both location usage descriptions required by the
Geolocation plugin. It only requests location while the app is in use. The app’s
PrivacyInfo.xcprivacy declares the Preferences plugin’s use of UserDefaults to
save app settings, and is included in the target’s resources.
For an instance hosted on your local network, allow the iOS local-network prompt. The app permits local HTTP connections; public instances should use HTTPS.
Branded builds and embedding an instance URL
Section titled “Branded builds and embedding an instance URL”To ship an app that always connects to one instance (hiding the gate and the
Profile → Instance switcher), set VITE_DIADEM_INSTANCE at build time:
VITE_DIADEM_INSTANCE=https://map.example.com pnpm run build:native:androidcd android && ./gradlew assembleDebug # or bundleReleaseOr put it in a .env file (gitignored) so every build picks it up:
VITE_DIADEM_INSTANCE=https://map.example.comWhen set:
- the first-run instance gate is skipped, the app connects straight to that URL,
- the Instance section in the profile menu is hidden,
- the URL cannot be changed at runtime.
Leave VITE_DIADEM_INSTANCE unset to build the generic app with the instance gate.
Customising app identity
Section titled “Customising app identity”App id, name, icon and splash live in the native projects:
- App id / name:
capacitor.config.ts(appId,appName). The default id isee.malt.diadem, change it before publishing your own app. - Icons / splash: replace the generated assets under
android/app/src/main/res/with@capacitor/assets. The iOS app icon usesassets/apple_icon_composer/diadem.icon; edit it with Icon Composer. Xcode renders all supported sizes and appearances from its layers, including flat icons for older iOS releases. The iOS splash images live inios/App/App/Assets.xcassets/. - Deep-link scheme: the
diadem://intent filter is inandroid/app/src/main/AndroidManifest.xml; the iOS URL scheme is inios/App/App/Info.plist.