Native apps

A project is shared by a link and a QR code without a single native build. When it needs a binary of its own — for the App Store, Google Play or the desktop — lecodes app makes it.

What a shell is

A shell is a generated Xcode or Gradle project in the project's ios/ or android/ folder. It runs the compiled bundle from inside the app, offline, and it is never pushed to le.codes.

app.json carries what the shells are made from: the app's name and identifiers, its versions, the icon, the plugins and the settings of each platform. You edit app.json; lecodes app sync makes the shells match it. Your own native files (ios/App/*.swift, android/app/) are never touched.

Building needs the platform's tools: Xcode on a Mac for iOS, a JDK and the Android SDK for Android.

Create a shell: lecodes app init

bash
lecodes app init ios --team ABCDE12345
lecodes app init android --app-id com.acme.game

The shell starts on the newest release of the native SDK, and that version is written to app.json (ios.sdk, android.sdk), so a build made next month is the same build. lecodes app update moves the pin forward.

Make the shell match the project: lecodes app sync

bash
lecodes app sync             # every shell that exists
lecodes app sync android

sync compiles the bundle and puts it into the shell with the assets it names, picks the smallest variant of the native SDK that covers what the bundle uses (UI only, 2D, 3D, or all of it), brings in the plugins of app.json, and writes the files the CLI owns.

What app.json sets in a shell, on every sync:

keywhat it does
icona square image of 1024 px or more, rendered into every icon size; iconBackground is the backdrop of Android's adaptive icon
splashthe launch screen: { "background": "#RRGGBB", "image": "./splash.png", "size": 160 }, every part optional
urlScheme"myshop" — the app opens on myshop://… links; the link arrives as app.launchUrl and the url event
appLinks["https://shop.example/pay/"] — verified https links that open the app; sync prints the file each site must serve
privacyPolicythe address of the app's privacy policy, for the screens of a plugin that must show it
resources{ "remote": [globs] } keeps heavy assets on the server instead of inside the app
pluginsthe native plugins the app uses — below

Add a plugin to the shell: lecodes app plugin

A first-party plugin — the camera, the map, push notifications — is native code, so it is in a shell only when app.json lists it:

bash
lecodes app plugin add camera
lecodes app plugin add github:acme/lecodes-plugin-thing@v1.2.0
lecodes app plugin add ./plugins/acme-battery
lecodes app plugin                    # what is listed, and the versions pinned
lecodes app sync                      # nothing reaches the shell before this

The three forms are a first-party plugin by its id, a third-party plugin from a GitHub repository, and a plugin in a folder of the project (Write a native plugin). A third-party plugin is native code that runs inside your app: read it before you ship it. The versions are pinned in plugins.lock.json.

Check before you build: lecodes app doctor

bash
lecodes app doctor

doctor checks the toolchain, the synced bundle, the SDK version against app.json, the plugin pins, signing, the icons and the store keys. A problem that would fail the build fails the command; a softer one is printed with a hint.

Build and upload

bash
lecodes app build ios                  # the archive and the .ipa
lecodes app upload ios                 # to App Store Connect

lecodes app keystore create            # once: the Android signing key
lecodes app build android              # dist/<name>-<version>-<versionCode>.apk and .aab
lecodes app upload android             # to a Google Play track (internal by default)
  • build runs sync first.
  • A successful upload spends the build number, so the CLI moves ios.buildNumber and android.versionCode in app.json for the next build.
  • The Android key's path and passwords live in the project's .env, never in app.json. Back the key file up: an app signed with a lost key can never be updated.
  • lecodes app open opens the shell in Xcode or Android Studio.

The whole road to the stores — accounts, keys, review — is in App Store & Google Play.

Update the app without the store

A shell checks for a newer bundle when the app starts. The first start of an installed build waits up to 5 seconds for the check and runs the newest bundle; later starts run the newest bundle the phone already has, and a download is used on the next start.

This is on for a project that was pushed to le.codes: publishing the project updates the installed apps. "update": { "url": … } in app.json names your own hosting, and "update": false turns it off. A bundle is taken only when it is of the shell's SDK major version — a change of the native side still goes through the store.

Build for the desktop: lecodes app build desktop

The desktop needs no shell:

bash
lecodes app init desktop               # writes the desktop block of app.json (the window's size)
lecodes app build desktop --zip

The result is a portable folder dist/<name>/ — the host renamed to your app, the bundle, the assets — that runs where it is unpacked. On macOS it is a signed .app; --dmg also makes a disk image and --notarize <profile> notarizes it. --probe renders the built folder to a PNG: the proof that what ships starts.

Test push notifications: lecodes pn

bash
lecodes pn devices                               # which devices registered for this project
lecodes pn send --title "Order shipped" --user u42

pn send uses your login, so testing needs no key. A device appears after the app calls Push.register() in a published project (a lecodes dev session cannot register). `lecodes pn keys new "prod server"` makes the key your own server sends with.

Next