Mobile
Mobile CLI and devices
Add the native projects, test the app on a phone against your own machine and prepare a release.
This page covers the frigear-mobile command, testing on a phone, Android and the steps before a release. It is for
app developers. Set up the module first: Overview.
CLI
The package ships the frigear-mobile command, which sets up and checks the native iOS and Android projects.
frigear-mobile native [--platform ios|android] [--if-missing] [--cwd <dir>] # cap add + URL schemes, idempotent
frigear-mobile doctor [--strict] [--cwd <dir>] # plugins and native projects
nativeadds the missing iOS and Android projects withcap add, for each platform whose package (@capacitor/iosor@capacitor/android) is installed. Then it registers the OAuth redirect and deep-link schemes inios/App/App/Info.plist(withNSAllowsLocalNetworking) and inandroid/app/src/main/AndroidManifest.xml(with verified app links). Running it again changes nothing.--if-missingleaves existing platform folders alone.doctorchecks that the app depends on@capacitor/cliand every plugin a feature uses, and that the native projects register the URL schemes.--strictexits with1on errors, for CI.
Both read the app's settings from .nuxt/mobile/native.json, and run nuxt prepare first when it is missing.
Device development
There are two ways to run the app on a phone against a server on this machine.
- Live reload (
nuxt dev --host 0.0.0.0,cap run ios --live-reload).nuxt-capacitorpoints the app at the dev server. Auth in client mode rewrites alocalhostissuer and API base to that host. - A build on a phone.
MOBILE_LAN=1 nuxt generaterewriteslocalhostto this machine's LAN address.MOBILE_LAN=192.168.1.20picks the address. It never applies innuxt dev.
| Variable | Purpose |
|---|---|
MOBILE_LAN | 1 (or true) detects the LAN address; an address fixes it. |
MOBILE_RELEASE | 1 marks a release build. Combined with MOBILE_LAN, it fails the build, so a LAN address never ships. |
Android
Android uses the web tab bar and header by default; see Native chrome. The back button closes an open overlay, goes back, returns to the first tab, then minimizes the app.
Prefer live reload on Android. The WebView's origin is
https://localhost, so a plain-http development server is
mixed content.Release checklist
Check these before a build goes to a store.
Never ship a
localhost or LAN address. Build releases with MOBILE_RELEASE=1, so MOBILE_LAN cannot slip in.- Install every plugin
frigear-mobile doctorlists, as dependencies of the app. - Install
@aparajita/capacitor-secure-storagewhen the app signs in. Without it a production build fails, because tokens would be stored unencrypted.authentication.client.storage: 'preferences'accepts that. - Register the redirect URI
<scheme>:/auth/callbackat the issuer. The scheme is the app id in lowercase, with_as-. Allowcapacitor://localhostandhttps://localhostfor CORS at the issuer and on your API. See Use your own OAuth server. - Point
issuer,apiBaseandclientIdat production, throughNUXT_PUBLIC_AUTHENTICATION_CLIENT_*. - Check the guards (Sign-in), and keep privileged data out of the bundle.
- Run
frigear-mobile nativeandfrigear-mobile doctor --strict, thennuxt generateandcap sync. - Check that no client secret is in the bundle. The build refuses one.
Next steps
- Mobile starter – see these commands wired into run scripts for iOS and Android.