Skip to content

The launcher ships its build tools and Python, so a player needs no Homebrew - #121

Closed
v0lumehi wants to merge 5 commits into
LNPANDY:mainfrom
v0lumehi:bundled-tools
Closed

v0lumehi wants to merge 5 commits into
LNPANDY:mainfrom
v0lumehi:bundled-tools

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Builds on #117.

The release app now carries the build tools and a Python, so a player installs neither Homebrew nor Python.

What is bundled

In NX2Apple.app/Contents/Resources:

Version License From
tools/bin/zstd 1.5.7 BSD-3-Clause OR GPL-2.0 source tarball, sha256-pinned
tools/bin/glslangValidator glslang 16.6.0 BSD-3-Clause, Apache-2.0, MIT, GPL-3.0-or-later (build files) source tarball, sha256-pinned
tools/bin/spirv-cross vulkan-sdk-1.4.363.0 Apache-2.0, MIT source tarball, sha256-pinned (the tag dm/gfx/tools/spirv_cross_bin/build.sh builds)
tools/bin/xcodegen (+ tools/share/xcodegen) 2.46.0 MIT the project's release zip, sha256-pinned
python/ CPython 3.13.18 (python-build-standalone 20261026, install_only arm64) PSF release tarball, sha256-pinned
Python packages lz4 4.4.5, capstone 5.0.9, fonttools 4.68.0, backports.zstd 1.8.0, nsz 5.0.0 and its dependencies (all pinned in frontend/tools/bundled-python-requirements.txt) their own pip, --only-binary, at build time

License files go to tools/licenses (the tools' and each Python package's).

Why not Homebrew's bottles (the design suggested them first): they are built for the macOS they are poured on (bottles of 2026 say minos 15 or later; the launcher now requires macOS 26.6, which they would meet, but they still need their dylibs copied and re-pathed and are pinned only by a registry digest) and link their siblings from /opt/homebrew (zstd: libzstd, liblzma, liblz4; glslang: libglslang, SPIRV-Tools). frontend/tools/bundle_tools.sh builds the tools from the pinned sources with MACOSX_DEPLOYMENT_TARGET=26.6 and static libraries instead, so each is one file linking only /usr/lib (libSystem, libc++) and, for xcodegen, the system's Swift libraries. glslang is built without the SPIR-V optimizer (the repo only calls glslangValidator -V/-E/--version). No install_name_tool rewriting is needed.

Size

The macOS zip grows from 2.6 MB to 53.1 MB (+50.5 MB; tools 21 MB and Python 121 MB unpacked, 151 MB app). Python's test suite, IDLE, turtle demos and Tk are dropped. The release uploads the zip under three names, so the release assets grow three times.

Launcher

  • BundledTools.swift: the bundled tools/bin and Python from Bundle.main.resourceURL, nil outside a .app (swift run).
  • Dependency rows: a bundled tool counts as present and its row says "bundled" (en and zh). Homebrew's copy is used when the bundle lacks that tool. With a bundle, the Homebrew row appears only when some tool is neither bundled nor installed; with no bundle it stays, as before.
  • Python row: the bundled Python is used when it runs, is 3.12 or newer and imports the packages; no venv. A damaged copy falls through to the old search.
  • One PATH helper, BuildModel.toolPath, replaces the four build-related PATH strings (build, nsz install, RomFS image, venv): bundled tools/bin, then the bundled Python's bin, then the old directories. The git, dotnet and stage-command environments are untouched.
  • The build runs the bundled Python with PYTHONDONTWRITEBYTECODE=1, so no .pyc is written into the signed app.
  • scripts/build_ipa_from_nsp.py needs no change: it finds tools with shutil.which on the PATH the launcher passes and runs with sys.executable. One thing to know: the script prepends /opt/homebrew/bin and /usr/local/bin to that PATH itself (TOOL_PATHS), so on a Mac that also has Homebrew's copy, the script uses Homebrew's. Both work; the bundle matters where Homebrew is absent. It also builds with its own in-repo spirv_cross_bin/spirv-cross; the bundled spirv-cross is for the check and for tools that call it by name.

Signing

bundle_tools.sh ad-hoc signs every Mach-O file under tools and python (62 files) itself, because codesign --deep does not reach code in Resources. Then the app is signed as before. codesign -v --deep --strict passes, also on a copy unzipped elsewhere.

Unchanged

.NET stays as it is (dotnet-install.sh into ~/.dotnet), Xcode and the iOS SDK and Metal toolchain are still the player's. The Brewfile stays for source users and CI. scripts/, dm/, docs/ are untouched.

Tests

  • swift test: BundledToolsTests (fake bundle: detection precedence, the Homebrew row rule, the Python choice, the PATH helper, and that the pinned packages cover pipPackages). swift build -c release passes.
  • frontend/tools/check_bundle.sh, run by the workflow after assembling and by hand: each tool runs from the bundle with env -i PATH=/usr/bin:/bin (zstd --version, glslangValidator --version, spirv-cross --help, xcodegen --version), the bundled Python imports lz4, capstone, fontTools, nsz and zstd and has the bundle as its prefix, no Mach-O file links outside /usr/lib, /System/Library or the bundle (nothing into /opt/homebrew) and none needs macOS later than 26.6.
  • The workflow also runs on pull requests that touch frontend/ or itself (artifact only, no release), so this PR's CI assembles the real bundle.
  • Run locally on an Apple-silicon Mac: the same steps into a scratch folder, all checks pass.

Not tested: a Mac on exactly macOS 26.6 (checked with otool), an Intel Mac (the app is arm64 only), a build of a game from the launcher with the bundled tools (no game files here).

Floor: macOS 26.6

Second commit: the launcher's macOS floor (a default from its first commit) is now what upstream requires, macOS 26.6 and Xcode 27.1. Package.swift (.macOS("26.6"), accepted by swift-tools 5.9), LSMinimumSystemVersion, the tools' deployment target, and the player requirements in README.md and README.zh-CN.md (no Homebrew or Python for players; the build-from-source section keeps them). There were no #available branches to remove.

Screenshots

Settings → Build tools → Device dependencies with a fake bundle that holds the four tools and a Python (English): every tool and the Python row say "bundled", and there is no Homebrew row. Rendered offscreen from the branch. A bundled tool's row is named by the tool ("zstd", "glslangValidator", "spirv-cross", "xcodegen"); the "brew: …" label stays on rows that refer to a Homebrew copy.

Compatibility cost

The launcher's minimum goes from macOS 13 (Package.swift and LSMinimumSystemVersion on main) to 26.6.

What it buys

  • The launcher's floor matches what the build needs anyway. The README already requires macOS 26.6+ and Xcode 27.1, and Xcode 27.1's own Info.plist says LSMinimumSystemVersion 26.6 (checked on this Mac with Xcode 27.1). A launcher that opens on macOS 13 to 26.5 cannot build anything there.
  • The bundled tools and Python are built and checked for one target, 26.6 (MACOSX_DEPLOYMENT_TARGET=26.6, and check_bundle.sh fails on any Mach-O file that needs later). There is no 13 to 26.5 matrix that we cannot test.
  • The game Mac apps do not get the launcher's floor. dm/mac/pack_app.py min_os() reads the host's LC_BUILD_VERSION minos, and dm/host/Makefile sets no -mmacosx-version-min, so the host takes the building Mac's default (a plain clang on this macOS 27 Mac gives minos 27.0). A game built on macOS 26.6 needs 26.6, one built on macOS 27 needs 27. So the 26.6 floor does not widen or narrow what a built game runs on; the game's minimum is whatever the Mac that built it had.

Who it leaves behind

  • No hardware. The app is arm64 only, and macOS 26 Tahoe runs on every Apple-silicon Mac (M1 and later). Only Intel Macs are out, and the app never ran there.
  • People who have not updated, or cannot for policy reasons. On macOS 13 to 26.5 the old launcher opened but could not build (no Xcode 27.1). What they lose is the parts that are not the build: opening the library, installing an already-built IPA by cable (nxnative for Mac: install an iPhone build on a paired device #28) and Launch options. They keep v0.5.x.
  • A commit in this PR adds an update guard, so they are not broken by an update. After downloading and unpacking, the updater reads the new bundle's LSMinimumSystemVersion. If it is above the running macOS, nothing is installed. The update sheet and the status line say "NX2Apple needs macOS and this Mac has " (en and zh), and the running version stays. Without it, an older launcher would replace itself with a 26.6-only app that does not open. Unit tests cover the version comparison, the decision and staging.

For Andy (releases)

This changes the supported-OS line in the README and the release notes. The release notes of the version that ships this should state the new minimum, macOS 26.6.

v0lumehi added a commit to v0lumehi/NX2Apple that referenced this pull request Oct 28, 2026
…omebrew

The release app carries zstd, glslangValidator, spirv-cross and xcodegen (Contents/Resources/tools/bin, built from pinned sources for macOS 13 with static libraries) and a relocatable CPython 3.13 with the packages the build scripts import. The dependency check prefers them to Homebrew's and to a system Python and shows 'bundled'; the build's PATH starts with them. Without a bundle (swift run, older builds) nothing changes.
Package.swift, the bundle's LSMinimumSystemVersion, the bundled tools' deployment target and the player requirements in both READMEs say macOS 26.6 or later, Xcode 27.1; the requirements no longer list Homebrew or Python, which the app carries.
The row says zstd, spirv-cross, xcodegen or glslangValidator with the detail bundled; the brew: label stays on rows that refer to a Homebrew copy (installed there, or missing with the install button).
After unpacking, the new bundle's LSMinimumSystemVersion is compared with the running macOS. Above it, nothing is installed: the update sheet and the status line say that NX2Apple <version> needs macOS <min> and this Mac has <current>, and the running version stays.
@LNPANDY

LNPANDY commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Thank you — the work is careful (pinned sources, static builds, ad-hoc signatures, 21 tests), and it would remove exactly the class of pain users hit with Homebrew today (/opt/homebrew not writable → every install button fails).

Decision: not now. The cost that stops it is the macOS floor: bundling the tools raises the minimum to 26.6, and that cuts off users who are otherwise fine with an older Xcode. The dependency problem is real, but we will solve it from the other side first: complete, actionable error messages for every dependency/build failure (a new issue is open for it), so a user whose Homebrew is broken reads what to type instead of a one-second spinner.

Keeping this open as the future direction if the floor ever moves for another reason; closing it for now so it does not read as pending. Please don't take it as a judgement of the work itself — it is the strongest PR of the batch in engineering terms.

@v0lumehi

Copy link
Copy Markdown
Collaborator Author

Fair point, and the floor was my mistake: the bundling doesn't need it. The first commit of this PR built the tools for macOS 13; I raised the floor afterwards to match upstream's Xcode 27.1, but as you say, non-NVN games (and NVN with --allow-other-metal) still build with an older Xcode. So I'll split it: a new PR with just the bundled tools and Python, built for macOS 13 like the launcher today, plus the update guard (harmless at any floor). That keeps every current user.

Why I'd still like the bundling soon:

  • It's where players get stuck. I've talked to a number of people on Instagram and Reddit who gave up during setup, and almost always on this part, not on keys or games: installing Homebrew (Terminal, admin password, Command Line Tools), /opt/homebrew not writable (the case you mentioned), an Intel Homebrew on Apple silicon, a system or Homebrew Python that is too old or refuses pip install (PEP 668), and backports.zstd with no build for Python 3.14. Every one of those is a separate support conversation. With the tools and Python inside the app, that whole class goes away, because there's nothing left to install.
  • The first-run setup (The launcher has a guided first-run setup, previewable with NSPB_ONBOARDING_DEMO (view layer) #119/The launcher walks a new player through setup with the real detection and installs (guided first run) #120) depends on it. The onboarding can guide Xcode through the App Store with one password prompt, but Homebrew can't be installed that way: its installer needs an interactive sudo session and refuses to run as root, so from inside an app it either fails or has to send the player to Terminal. Without bundling, the onboarding's "preparing in the background" step is exactly the step that breaks. With bundling, it's instant and needs no admin rights.
  • Your error-message issue still matters: for what can't be bundled (Xcode, the Metal toolchain, the iOS platform, .NET), clear "what to type" messages are the right fix, and the onboarding will show the same messages.

The new PR follows as a feature PR (48h), with the compatibility section saying the floor stays at macOS 13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants