# Building on macOS Building on macOS is a few separate steps: build `desktop-sdk` natively, stage the result, apply branding/version, then build the Xcode project. `build/macos/stage.sh` handles the staging step — overlaying the web payload onto a built `desktop-sdk` tree and generating fonts/theme thumbnails. It does **not** build `desktop-sdk` itself, and it does **not** run the Xcode build. > New here? Read the **[build overview](../README.md)** first — it explains the > three CI jobs, the common payload, vcpkg, and caching, none of which are > repeated below. ## Prerequisites - Xcode with the `Euro-Office-arm` scheme (`desktop-apps/macos/Euro-Office.xcodeproj`). - **CMake**, **Ninja**, and **vcpkg** (bootstrapped) on `PATH`. - Homebrew `autoconf`, `automake`, GNU `libtool` (not Apple's `/usr/bin/libtool`), and `pkg-config` — needed by vcpkg's `hunspell` port. - The submodules checked out (see the [overview](../README.md#prerequisites-all-platforms)), including `core-fonts`. - Docker, for building the [common payload](../README.md#the-common-payload-again) locally. Use `type=tar`, not the default `type=local` — `type=local` is known to hang indefinitely on Docker Desktop's macOS/virtiofs backend for this many small files (confirmed stuck, not just slow), and `type=tar` is also what CI already uses: ```bash docker buildx bake desktop-common --set desktop-common.output=type=tar,dest=./build/deploy/common.tar mkdir -p build/deploy/common && tar -xf build/deploy/common.tar -C build/deploy/common ``` ## The steps Set these once and reuse them across all the steps below: ```bash REPO=/path/to/your/checkout VCPKG=/path/to/vcpkg EO_3RDPARTY=/path/to/3rdparty-cache STAGE=/path/to/staging-root # arbitrary, doesn't need to exist yet - step 1 creates it ``` 1. **Build `desktop-sdk`** (the native `ascdocumentscore.framework`, the 3 `editors_helper*.app` bundles) against core (`x2t`, every converter, `ooxmlsignature.framework`, `allfontsgen`/`allthemesgen`), with desktop-apps' build script: ```bash VCPKG_ROOT="${VCPKG}" "${REPO}/desktop-apps/scripts/build.sh" \ --build-dir build-mac-sdk --third-party-dir "${EO_3RDPARTY}" \ -- -DEO_CORE_OUTPUT_DIR="${STAGE}/converter" -DEO_CORE_TOOLS_DIR="${STAGE}/converter" ``` It downloads the prebuilt core for the `core` checkout when the build cache has it, and builds core first otherwise, or when `core` has local changes. The first run fetches boost/openssl/icu/cef (and v8, when building core) via `build_3rdparty.py` — expect this to take a while and need several GB free. Confirm it worked: `${STAGE}/ascdocumentscore.framework`, `${STAGE}/ooxmlsignature.framework`, `${STAGE}/editors_helper.app` (+ GPU/Renderer variants), and `${STAGE}/converter/x2t` should all exist. 2. **Stage it** — this is what `stage.sh` automates: ```bash "${REPO}/build/macos/stage.sh" --stage-dir "${STAGE}" ``` (`--payload-dir` and `--core-fonts-dir` default to `build/deploy/common` and `core-fonts` under the repo root — override with flags or the matching env vars if yours live elsewhere.) 3. **Apply branding/version** — patches the committed `Info.plist` in place with the company/product name and version to actually ship. Run this every time: the committed file is just whatever was last checked in, and nothing else keeps it in sync, so don't rely on it already being correct. ```bash "${REPO}/desktop-apps/macos/apply-branding.sh" \ --company-name Euro-Office \ --product-name Euro-Office \ --version "$(cat "${REPO}/VERSION.txt")" ``` This is exactly what CI's own "Apply branding" step in `build-macos` runs before `xcodebuild` — patches `NSHumanReadableCopyright`/`CFBundleName`/ `CFBundleShortVersionString`. Use different `--company-name`/`--product-name` values to build a different brand (e.g. nextcloud-office). 4. **Build the Xcode project**, pointed at the staged tree: ```bash xcodebuild -project "${REPO}/desktop-apps/macos/Euro-Office.xcodeproj" \ -scheme Euro-Office-arm -configuration Release \ EO_MAC_STAGE_DIR="${STAGE}" \ CONFIGURATION_BUILD_DIR="${REPO}/build/macos/out" \ build ``` `Euro-Office.app` lands directly at `${REPO}/build/macos/out/Euro-Office.app` — without `CONFIGURATION_BUILD_DIR`, Xcode uses its default DerivedData location instead (`~/Library/Developer/Xcode/DerivedData/Euro-Office-/Build/Products//`). 5. **(Optional) Package a DMG installer** — `make-dmg.sh` packages the built `.app` into a distributable `.dmg` (app + `/Applications` symlink, background graphic), using [`appdmg`](https://github.com/LinusU/node-appdmg) and the config/assets in `desktop-apps/macos/fastlane/resources/`. Needs Node/npm on `PATH` (not required for steps 1-4) — CI's macOS runners have it by default. ```bash "${REPO}/build/macos/make-dmg.sh" \ --app "${REPO}/build/macos/out/Euro-Office.app" \ --output "${REPO}/build/macos/out/Euro-Office-DesktopEditors-9.3.5-1-macos-arm64.dmg" ``` ## What `stage.sh` does In order: merge the CMake build's `package/` output into `converter/` → merge the web payload (`index.html`, `editors/`, `fonts/`, `providers/`, plus `converter/`'s extra config/locale files) → run `allfontsgen` (native + web `AllFonts.js`, `font_selection.bin`) → run `allthemesgen` (slide-theme thumbnails) → move both generator binaries from `converter/` to `stage-generators/` so they don't ship. Mirrors the equivalent sequence in Linux's `desktop-apps/.docker/desktop-apps.bake.Dockerfile` and Windows' `build.ps1` (step 9/9b) — **matching Windows' version specifically**, not Linux's: Windows passes `--allfonts-web=`/`--output-web=` to `allfontsgen`, Linux's Dockerfile doesn't. Omitting them silently drops the web `AllFonts.js` that `doctrenderer` needs, which then makes `allthemesgen` fault — Windows' own comment documents this exact gotcha, and it's why this script follows Windows' fuller flag set. ## Good to know - **Verifies real output, not just exit codes.** `allfontsgen` can exit `0` while writing essentially nothing — a real failure mode, not a theoretical one. The script checks file sizes, not just existence or exit status, to catch that class of failure. - **Safe to re-run.** Each run fully replaces `editors/`, `fonts/`, and `providers/` from the payload dir and regenerates the font/theme data from scratch, so stale content from a previous run doesn't linger. The generators are moved back from `stage-generators/` for the run. - **`--stage-dir` must already have a built `package/`.** The script fails fast with a clear message if it doesn't, rather than staging a broken tree.