phigros.tools

Development

CommandWhat it does
makeBuilds the library and the signed APKs in out/
make install-fullFirst install on a device, next to the game
make devInstalls the native split, pushes the mods, restarts the game and follows the log
make pushCopies mods/ and examples/ to the device, where they override the bundle's mods
make push-corePuts phigrospp/lua/ on the device so it overrides the bundle's core
make resetRemoves what push and push-core put there, and any downloaded bundle
make verify RELEASE=<folder>Checks that a release's APKs are the ones these sources build
make releaseSigns the bundle for a GitHub release (see Updates)
make apiWrites the wiki's Mod API page from api.lua, where the API is documented for editors too
make logsFollows adb logcat -s phigros++
make start / stop / restartControls the game
make iosBuilds build/phigrospp.ios, what patches the iOS game (see below)
make ipaPatches the game's IPA into build/Phigros++.ipa (see below)
make ios-logsFollows the iPhone's log with idevicesyslog

Clone with --recursive for the submodules in vendor/ (Lua, Opus, Dobby). APKS=../apks/<version> picks the game version to build from. A local examples/ folder (in .git/info/exclude) holds mods showing the API, like the UI gallery: make push sends them along, they never ship.

iOS

Phigros++ runs on iOS from the game's own IPA, which must be decrypted (cryptid 0, the IPAs passed around usually are). phigros.tools patches it in the browser, and make ipa IPA=<the IPA> does the same here: both run scripts/ipa.ts, which copies the IPA with Phigros++ in it. UnityFramework loads the library, the app becomes Phigros++ (sh.molly.phigrosplusplus) and the store's signature and data are left out. Install it with AltStore or SideStore, which sign it with your Apple ID, and launch it like any app.

What it patches with is build/phigrospp.ios (make ios, scripts/build-ios.ts): the library built for each iOS game of phigrospp/GAMES, and the strings and names of the core and mods/. No game file goes in it and none is needed to build it. A release carries it signed by the release key (Updates), and phigros.tools patches with the latest release's once the page checked that signature.

iOS doesn't let an app change its code, so scripts/ipa.ts writes the hooks into UnityFramework beforehand: every method the core and mods/ may hook (its name is a string or a table key in them, its class a name in them) jumps to a stub that runs Phigros++'s hook once it's set, the method itself until then. It finds the methods as Il2CppDumper does, from the game's global-metadata.dat (version 31) and the tables UnityFramework registers its code with, and names them as its script.json does. A mod hooking another method needs it in mods/ when phigrospp.ios is built, or JIT: Phigros++ then writes that hook itself with Dobby.

Since iOS 26 even JIT only lets a debugger write code, so for those hooks the debugger must stay attached: Phigros++ gathers its hooks and stops on brk #0xf00d with the pages to write in, which scripts/jit.py serves from lldb. From a Mac with Xcode, launch the app suspended (xcrun devicectl device process launch --start-stopped), attach with device select <udid> and device process attach -p <pid> in xcrun lldb, then run command script import scripts/jit.py, target stop-hook add -P jit.Serve -I false and continue. On a device on Wi-Fi, settings set target.memory-module-load-level minimal first keeps each stop quick. Once the log says the mods loaded, process detach can let the game go on alone: hooks set after that in code nothing hooked before wait for the next launch (the log says so).

Mods and charts go in phigros++/ of the app's folder, which the Files app shows under On My iPhone. There's no make push on iOS: copy the files there and the game reloads as on Android. The log is also written to phigros++/log.txt, and make ios-logs follows it over USB.

Reproducible builds

The same commit and the same Phigros APKs always build the same APKs, apart from their signature. shell.nix pins the tools (nixpkgs at a fixed commit), and nothing in the build depends on the date, the folder or the machine. The game's APKs can't be published from CI, so anyone can check a release on their own machine instead.

Get the Phigros APKs the release was built from (its notes list their SHA-256), for example from a device with Phigros from the Play Store with adb shell pm path com.PigeonGames.Phigros and adb pull, into ../apks/Phigros-<version>/.

Download the release's APKs into a folder and check out its tag.

make verify APKS=../apks/Phigros-<version> RELEASE=<folder>. It builds, signs with your own key, then copies the release's signature onto each APK and checks it still verifies: one byte of difference fails.

phigrospp.ios holds nothing of the game, so GitHub Actions builds it too (.github/workflows/ios.yml, on a release's tag) and prints its SHA-256. A release's file is that one behind the 64 bytes of its signature: tail -c +65 phigrospp.ios | sha256sum gives the same hash, as make ios does on the tag's sources.