A fresh clone leaves a submodule's folder empty, and git looks upward, so `git -C <empty folder>` answered for the app's own repo: rl16build then reported the app's commit as RedWhiteUI's and tried to check RedWhiteUI's newest commit out in the app. Only a folder with a .git of its own counts now. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Ug8WAdn5H4r3oi1q2LdYaY
rl16build
A command-line tool (Swift, for macOS and Linux) that builds every app in one go:
- every Xcode project under
~/Documents/Swift: iOS always, macOS where the project has a macOS app, and every watch app as an.ipaof its own; - every Android and Wear OS app module of every Gradle project under
~/Documents/Kotlin, as a signed release.apk(the arm64-v8a split when an app splits by ABI);
moving each project's RedWhiteUI to the library's newest main first (or another branch's, with
--branch). On Linux the same tool builds the iPhone apps with xtool instead of Xcode; see
Linux (xtool).
Build and install
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift build -c release
ln -sf "$PWD/.build/release/rl16build" /opt/homebrew/bin/rl16build
swift test (with the same DEVELOPER_DIR on the Mac) runs the tests: what is built where, the
skip reasons, the key-folder guard, the xtool arguments and the folder overrides.
Use
rl16build # asks what to build for and whether to clean first
rl16build --clean # clean build, no question
rl16build --no-clean # incremental build, no question
rl16build --for ios android # only these platforms: ios, macos, watchos, android, wearos (or all)
rl16build --only WFHelper 2048 # just these folders (in Swift and Kotlin)
rl16build --branch my-fix # RedWhiteUI from this branch instead of main (Swift and Kotlin); -b for short
rl16build --app-branch main # every app's own repo onto this branch, pulled, before building
rl16build --resolve-only # only update RedWhiteUI everywhere
rl16build --dry-run # show what would be built, build nothing
rl16build --extract-watch # cut the watch apps out of the .ipa files already in Build/iOS
rl16build --no-upload # build, but keep the .ipa files to yourself
rl16build --upload-only # build nothing: upload every .ipa already in Build/iOS and Build/watchOS
rl16build --upload-only RedMail # … or just these
rl16build --set-upload-key # ask for the upload key and keep it in the login Keychain
rl16build --set-upload-key --key-file # … in ~/.config/rl16build/<site>.key instead (mode 600)
rl16build --new-keys # make Android release keys even with no Keystores folder
The folders can be moved, on either system, with environment variables:
| Variable | Default |
|---|---|
RL16BUILD_SWIFT_ROOT |
~/Documents/Swift |
RL16BUILD_KOTLIN_ROOT |
~/Documents/Kotlin (its Keystores moves with it) |
RL16BUILD_OUTPUT_ROOT |
the Swift folder's Build |
--branch is for trying a library change before it reaches main: both libraries move to that
branch's newest commit (a Swift pin is moved by hand, since SwiftPM's own update goes to the branch
project.yml names). A library without the branch stays on main, and the next run without
--branch moves everything back.
--app-branch switches each app's repo to that branch and fast-forwards it to its remote's newest
commit, before XcodeGen, RedWhiteUI or the build number see it, and leaves it there. A repo with
changes of its own isn't switched (one already on the branch is still pulled; git won't touch the
changes), and one without the branch is built as it is; each gets a line saying so. What rl16build
changes by itself (XcodeGen's projects, Package.resolved, redwhiteui.lock, the RedWhiteUI
checkout, .gradle/, .DS_Store) doesn't count as a change, and is put back if it would stop a switch.
Output, and nothing else:
| Path | What |
|---|---|
Build/iOS/<App>.ipa |
Ad Hoc export, as Xcode's Organizer makes it |
Build/macOS/<App>.app |
the archived app |
Build/watchOS/<App>.ipa |
every watch app on its own |
Build/Android/<App>.apk |
a signed release build of every Android app module |
Build/WearOS/<App>.apk |
the same for a Wear OS app |
Build numbers
Every build is stamped with its repo's commit count, so the number goes up by itself:
CURRENT_PROJECT_VERSION on Apple (the app, its extensions and its watch app alike) and
versionCode on Android (never lower than the project's own, since Android won't install a
lower one over a higher one). The version name (MARKETING_VERSION / versionName, e.g.
0.1.0) is still yours to bump.
An Apple app whose Info.plist writes CFBundleVersion out ("2") instead of
$(CURRENT_PROJECT_VERSION) keeps its number; the summary says so on that app's line.
Uploads
Every .ipa a run makes (iPhone and watch) is sent to ipas.redlintu16.com once the builds are
done (POST /api/upload, the file in the form field ipa), replacing that app's previous version
there. The upload key comes from $IPA_UPLOAD_KEY, else the login Keychain (generic password,
service ipas.redlintu16.com, account upload-key), else it is asked for once at the start of the
run and offered to the Keychain; Enter there skips the uploads. The key never goes on a command
line: curl reads the header from a file only you can read, deleted afterwards.
A refused key (404, as the server answers one, or 401) or the server's lockout (429) stops the uploads, so the rest aren't counted as more wrong keys.
Cloudflare refuses requests over 100 MB, so an .ipa over 95 MB goes around it: the server
hands out a presigned R2 upload link ({"r2": "start"}), the file goes straight to R2, and the
server takes it in from there ({"r2": "finish"}) like any upload — the result line ends in
"via R2". That needs the server's R2_* settings (see its README). $IPA_UPLOAD_URL points
the uploads at another server, a test one say.
Android release keys
One key per app (application ID), made the first time the app is built, in
~/Documents/Kotlin/Keystores, with every password in passwords.txt there. Nothing about the keys is
stored in this repository. Back that folder up: an installed app only takes updates signed with its
own key. A project that signs its releases with a key of its own keeps it.
With no Keystores folder at all (a new machine), rl16build builds nothing for Android and says why:
copy the folder over from the Mac (below), or pass --new-keys to really start new keys, after which
every app has to be uninstalled once before its new build goes on.
Linux (xtool)
The same tool and the same commands, on Linux (Arch here). The iPhone apps are built with
xtool 2.0 (beta), which builds the .xcodeproj XcodeGen makes from each
project.yml, so the projects stay as they are; Android and Wear OS are built with Gradle as on the
Mac. For each iPhone app rl16build runs
xtool dev build --configuration release --scheme <the app's scheme> --ipa --sign
(--sign only when xtool auth status says you're logged in) in a folder of its own,
~/.cache/rl16build/xtool/<folder>, holding an xtool.yml that points at the project, so nothing of
xtool's lands in the app's repo. xtool takes no build settings on its command line, so the build
number (the commit count) is written into the generated project instead. --clean empties that
folder's xtool/, which holds xtool's DerivedData.
What Linux builds, and what it skips
- macOS and watchOS: not available on Linux (xtool). xtool's Darwin SDK has no watchOS at all, and Mac apps it builds but can't sign.
- An iPhone app with something only Apple's tools compile is skipped, with the file and the tool
named on its line and in the summary: an asset catalog, Icon Composer icon or sticker pack
(
actool), a storyboard or xib (ibtool), Metal (metal), a string catalog (xcstringstool), a Core Data model (momc), an intent definition (intentbuilderc) or a Core ML model (coremlc), in the app, its extensions or a local package it uses. xtool hands these to Swift Build as Xcode would, and on Linux the tool isn't there, so the build would fail. Right now every iPhone app here has anAssets.xcassets(the app icon), so Linux builds none of them until xtool can compile asset catalogs. - An iPhone app with a watch app inside is skipped too: the watch app is part of its build, and there is no watchOS SDK.
- App Intents: built, but xtool leaves the App Intents metadata out on Linux, so the app's
intents, App Shortcuts and widget buttons don't work. The app's line says so (
!). - ExtensionKit extensions: built and signed with the rest, but xtool doesn't support them yet, and the line says so.
- Uploads: none of the
.ipafiles go to ipas.redlintu16.com. xtool signs them for development, under bundle IDs of its own (XTL-<team or key>.<the app's>, extensions too), withkeychain-access-groupscut down to that ID (and with an API-key login, no App Groups). They aren't the Mac's builds and wouldn't update them. They install withxtool install Build/iOS/<App>.ipa(a USB-connected device).--upload-onlyon Linux looks inside each.ipaand sends only one with the app's own bundle ID and an Ad Hoc profile, such as a Mac build copied over. - macOS-only:
--extract-watch, xcode-select, codesign and the Keychain.
rl16build --dry-run shows all of it: what xtool would build, and what it skips and why.
Set up the Arch box
The base tools (zip and unzip are also what xtool packs an .ipa with, fuse2 runs its
AppImage, libsecret and gnome-keyring keep the upload keys):
sudo pacman -S --needed git curl zip unzip fuse2 libsecret gnome-keyring jdk17-openjdk
Swift 6.4, with swiftly (swift.org's installer):
cd ~ && curl -fLO "https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz" && tar zxf "swiftly-$(uname -m).tar.gz" && ./swiftly init --quiet-shell-followup && . "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh" && hash -r && swiftly install 6.4 && swiftly use 6.4 && swift --version
xtool 2.0 beta, into ~/.local/bin (an older xtool in /usr/local/bin can stay; rl16build uses the
first one on your PATH, and says which), then its one-time setup: your Apple login, and the Darwin
SDK from the Xcode .xip xtool's docs name:
mkdir -p ~/.local/bin && curl -fL "https://github.com/xtool-org/xtool/releases/download/2.0.0-beta.1/xtool-$(uname -m).AppImage" -o ~/.local/bin/xtool && chmod +x ~/.local/bin/xtool
grep -q '.local/bin' ~/.bashrc || echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc; export PATH="$HOME/.local/bin:$PATH"
xtool --version && xtool setup
XcodeGen isn't packaged for Arch; build it from source (it needs $USER set, as a login shell has):
git clone --depth 1 --branch 2.48.0 https://github.com/yonaskolb/XcodeGen.git ~/src/XcodeGen && cd ~/src/XcodeGen && swift build -c release && ln -sf ~/src/XcodeGen/.build/release/xcodegen ~/.local/bin/xcodegen && xcodegen --version
The Android SDK command-line tools (or the AUR's android-sdk-cmdline-tools-latest, which puts the
SDK in /opt/android-sdk); Gradle fetches the rest once the licenses are accepted:
mkdir -p ~/Android/Sdk/cmdline-tools && cd ~/Android/Sdk/cmdline-tools && curl -fLo tools.zip https://dl.google.com/android/repository/commandlinetools-linux-16111833_latest.zip && unzip -q tools.zip && rm tools.zip && mv cmdline-tools latest
yes | ~/Android/Sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root="$HOME/Android/Sdk" --licenses && ~/Android/Sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root="$HOME/Android/Sdk" "platform-tools" "build-tools;36.0.0" "platforms;android-36"
rl16build finds the JDK as $JAVA_HOME, else /usr/lib/jvm/java-17-openjdk or java-21-openjdk,
else the one archlinux-java get names; the SDK as $ANDROID_HOME, $ANDROID_SDK_ROOT,
~/Android/Sdk or /opt/android-sdk. A project's local.properties that names the Mac's SDK is
pointed at this one.
The app repos
The repos are private, so git needs your git.redlintu16.com login once (libsecret keeps it in the
keyring; store keeps it in ~/.git-credentials on a box without one):
git config --global credential.helper /usr/lib/git-core/git-credential-libsecret
On the Mac, write a clone command for every app repo, and copy it over:
for d in ~/Documents/Swift/*/ ~/Documents/Kotlin/*/; do url=$(git -C "$d" remote get-url origin 2>/dev/null) || continue; echo "git clone --recurse-submodules \"$url\" \"\$HOME/Documents/$(basename "$(dirname "$d")")/$(basename "$d")\""; done > ~/rl16build-clone.sh && scp ~/rl16build-clone.sh <you>@<linux-box>:
On the Arch box:
mkdir -p ~/Documents/Swift ~/Documents/Kotlin && sh ~/rl16build-clone.sh
The Android release keys
Copy Keystores from the Mac, so every app keeps the key its installed copies have (without it,
rl16build stops before building anything for Android). On the Mac:
scp -r ~/Documents/Kotlin/Keystores <you>@<linux-box>:Documents/Kotlin/
On the Arch box:
chmod 700 ~/Documents/Kotlin/Keystores && chmod 600 ~/Documents/Kotlin/Keystores/*
rl16build itself
[ -d ~/Documents/Swift/RL16Build ] || git clone https://git.redlintu16.com/RedLintu16/RL16Build.git ~/Documents/Swift/RL16Build; cd ~/Documents/Swift/RL16Build && swift build -c release && ln -sf "$PWD/.build/release/rl16build" ~/.local/bin/rl16build && rl16build --dry-run
After a git pull, swift build -c release again (the link follows it).
Upload keys on Linux
The APK uploads work as on the Mac. The key comes from $APK_UPLOAD_KEY, else your keyring (the
Secret Service: the same service and account names as the Mac's Keychain item, through
secret-tool), else the key file if you made one, else it is asked for. Over SSH there is often no
keyring to reach; then export the key for the run, or keep it in a file only you can read:
rl16build --set-apk-upload-key # into the keyring
rl16build --set-apk-upload-key --key-file # into ~/.config/rl16build/apks.redlintu16.com.key (600)