← Back
How to's

How to build Umfeld applications for Android and iOS

Umfeld has separate application templates for Android and iOS. Both keep the familiar application.cpp sketch at the project root and package the files in data/ with the app. The platform projects take care of SDL3, OpenGL ES, native audio, touch input, and the final mobile package.

Mobile support is experimental. Start with the templates rather than copying a desktop CMakeLists.txt: each template contains platform-specific build and packaging code.

How a sketch becomes a mobile app

application.cpp + data/
          │
          ▼
    Umfeld + SDL3 + CMake
          │
          ├── Android: Gradle + NDK ──► APK ──► emulator or device
          │
          └── iOS: Xcode toolchain ───► .app ─► simulator or device

The templates use the same smoke-test sketch: a touch-controlled 3D panda with audio and loaded font assets. Build it unchanged first. Once that works, replace application.cpp and the contents of data/ with your own sketch.

Before you begin

You need a local checkout of Umfeld. If you do not have one yet, follow the desktop setup guide first. Set UMFELD_PATH to its absolute path in every terminal used below:

export UMFELD_PATH=/absolute/path/to/umfeld

Add that line to ~/.zshrc or ~/.bashrc if you want it to persist.

Android

The Android template builds an arm64-v8a app with OpenGL ES 3.0. It currently requires Android 8.0/API 26 or newer.

1. Install the Android tools

The easiest setup is Android Studio. Install:

  • JDK 17
  • Android SDK Platform 35
  • Android SDK Platform-Tools
  • NDK (Side by side)
  • Android Emulator and an arm64 system image, if you want a virtual device

Set the SDK location. The usual paths are ~/Library/Android/sdk on macOS and ~/Android/Sdk on Linux:

export ANDROID_HOME=~/Library/Android/sdk  # adjust for your computer
export PATH="$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$ANDROID_HOME/cmdline-tools/latest/bin"

For detailed macOS, Linux, command-line SDK, and KVM instructions, see the Android template README.

2. Get and prepare the template

git clone --recurse-submodules https://codeberg.org/umfeld/umfeld-android-application.git
cd umfeld-android-application
bash scripts/setup.sh

3. Start a target

Either start an arm64 emulator from Android Studio → Device Manager, or connect an Android device with Developer options and USB debugging enabled. Confirm that ADB can see it:

adb devices

The device should be listed as device, not unauthorized.

4. Build, install, and launch

The included convenience script does all three:

./build.sh

To run each stage yourself:

./gradlew assembleDebug
adb install -r app/build/outputs/apk/debug/app-debug.apk
adb shell am start -n org.umfeld.android.application/.MainActivity

The APK is written to:

app/build/outputs/apk/debug/app-debug.apk

Capture a reproducible proof that the app launched:

adb exec-out screencap -p > frame-android.png

iOS and iPadOS

The iOS template builds for an arm64 simulator or a physical iPhone/iPad. It uses native OpenGL ES 3.0 and requires iOS 13 or newer. A Mac with full Xcode is required; the Command Line Tools alone are not sufficient.

1. Install the Apple tools

  1. Install and open Xcode, accept its licence, and select it as the active developer tools.
  2. In Xcode → Settings → Components, install an iOS platform and Simulator runtime that matches the installed iOS SDK.
  3. Install CMake: brew install cmake.

You can select Xcode and download the current platform from the terminal:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
xcodebuild -downloadPlatform iOS

2. Get and prepare the template

git clone --recurse-submodules https://codeberg.org/umfeld/umfeld-ios-application.git
cd umfeld-ios-application
./setup.sh

3. Build and run in the simulator

./build.sh

The script configures and builds the Xcode project, creates or boots a simulator, installs the app, launches it, and automatically captures frame.png. The app bundle is written to:

build-sim/Debug-iphonesimulator/umfeld-ios-application.app

For a different simulator model or a build without launching it:

SIM_DEVICE_TYPE="iPhone 15" ./build.sh
BUILD_ONLY=1 ./build.sh

4. Run on a physical iPhone or iPad

Sign in once at Xcode → Settings → Accounts. A free Apple ID is enough for local device testing, although its provisioning expires after about seven days. On iOS 16 or newer, enable Settings → Privacy & Security → Developer Mode on the device, then connect, unlock, and trust the Mac.

Find your 10-character Apple Developer Team ID and run:

export UMFELD_IOS_TEAM_ID=XXXXXXXXXX
TARGET=device ./build.sh

The script signs, installs, and launches the app on the first paired device. Set DEVICE_UDID=<id> if more than one device is connected. A free personal team may also require one-time approval under Settings → General → VPN & Device Management → Developer App on the device.

Publishing through TestFlight or the App Store requires a paid Apple Developer membership. The template can create an archive and export an IPA with:

TARGET=archive ./build.sh

Read the iOS template README before signing or publishing; it documents Team IDs, device trust, bundle registration, and App Store Connect.

Put your own sketch into the template

After the panda smoke test works:

  1. Replace the root application.cpp with your sketch. Additional root-level .cpp and .pde files are picked up by CMake.
  2. Replace the sample files in data/ with your assets. Keep loading them through normal Umfeld paths such as loadFont("MyFont.ttf", 24).
  3. Rebuild from the template root.
  4. Test touch, audio, suspend/resume, rotation, and asset loading on a physical device—not only an emulator.

Before distributing, also replace the template identity:

Platform Change these files
Android App ID, namespace, and versions in app/build.gradle; Java package/path for MainActivity; app name in app/src/main/res/values/strings.xml; icons in the mipmap-* folders
iOS Bundle ID in CMakeLists.txt and build.sh; versions in CMakeLists.txt; icons and launch images in ios/Assets.xcassets

Current limitations

  • The mobile templates intentionally disable some desktop-oriented Umfeld features to keep the build small, including video, PDF, MIDI, serial, clipboard, and native file dialogs.
  • Android still has a known OpenGL resource-restoration issue after context loss: an app may show a black or stale frame after being backgrounded.
  • Apple’s native OpenGL ES framework is deprecated, although it is still available. The iOS template documents ANGLE-on-Metal as the future migration path.
  • Android physical-device behavior and iOS signing can differ from simulator behavior. Treat a real-device run as part of the build, not as a final optional check.