Add macOS arm64 runtime support and release artifacts#1174
Open
kkorenn wants to merge 4 commits into
Open
Conversation
Add support for osx-arm64: add ARM64 platform and runtime identifier in Directory.Build.props and define an ARM64 build constant. Include osx-arm64 native libraries (libdobby.a and libplthook.a) and update the osx-x64 plthook. Implement a DYLD dlsym interpose flow because plthook cannot patch modern macOS GOTs: export MLRegisterDlsymHook, MLRealDlsym and MLMacOSJitCopy from native osxentry.cpp, register the managed detour from ModuleSymbolRedirect, and use RealDlsym to resolve genuine runtime symbols. Update the bootstrap project file to keep additional linker symbols and append native exports before native linking. Improve macOS-specific behavior: add JIT copy support for arm64, open a Terminal tailing the MelonLoader log from the macOS launcher script, better resolve the game .app path and frameworks path, and select the appropriate DetourNative platform for macOS ARM64. Also update osxexports.def with the new native exports.
datariot
added a commit
to datariot/MelonLoader
that referenced
this pull request
Jun 26, 2026
Builds on PR LavaGang#1174 (arm64 macOS native-detour platform / dobby) to get MelonLoader fully loading il2cpp games on Apple Silicon. Validated on Bloons TD 6 (Unity 6000.0.58f2) with native-arm64 class injection working. - MelonLoader/Core.cs: wire MacOSArm64NativeDetourPlatform for net6/il2cpp, not just Mono. LavaGang#1174 selected it only under `!NET6`; without this, HarmonyX/MonoMod (DetourHelper.Native) has no arm64 platform -> IL compile error / NullRef in MonoMod ILHook ctor when the Il2Cpp support module applies its hooks. (keystone) - Dependencies/Il2CppAssemblyGenerator/.../ExecutablePackage.cs: strip DYLD_INSERT_LIBRARIES when spawning the Cpp2IL subprocess, else the x86_64 Cpp2IL inherits the arm64 bootstrap insert -> dyld arch-mismatch crash. - MelonLoader/SupportModule/SupportModule.cs: surface support-module init failures via MelonLogger.Error (was MelonDebug.Error, debug-only) so swallowed exceptions are visible. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NNJ7xPHAVYU6JAMioxnFs8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
This PR contains the macOS arm64 runtime fixes plus the CI/release packaging needed to ship separate macOS x64 and arm64 archives.
Runtime and bootstrap fixes
arm64/osx-arm64to the shared build properties and solution configurations.libdobby.a,libplthook.a) and updates the macOS x64libplthook.a.dlsyminterpose support inosxentry.cppbecauseplthookcannot reliably patch modern macOS chained fixups in UnityPlayer.dylib.MLRegisterDlsymHook,MLRealDlsym, andMLMacOSJitCopyfrom the native bootstrap and keeps those symbols through the AOT/native link.ModuleSymbolRedirectso macOS uses the nativedlsyminterpose path, while still using the real un-interposeddlsymwhen resolving genuine runtime symbols.MLMacOSJitCopysupport for arm64 JIT writes usingpthread_jit_write_protect_npplus instruction-cache invalidation.MLMacOSJitCopyinstead of falling back to MonoMod legacymprotect/ MonoPosix writes.macOS launch/path fixes
.apppath detection on macOS so MelonLoader can resolve the game bundle correctly..appbundle in the game directory when the process path is not already the bundle path.CI/release fixes
osx-x64andosx-arm64in the macOS GitHub workflow matrix.MelonLoader.macOS.arm64.zipalongside the existingMelonLoader.macOS.x64.zipin GitHub releases.softprops/action-gh-release@v3inputs totag_name/name, enablesoverwrite_files, and grants the nested release upload workflowcontents: writeso an existing tag release can be updated.Why
Apple Silicon native macOS installs need both the runtime/bootstrap changes and a release artifact. The existing x64-only macOS release path forced Rosetta and did not handle the arm64 detour/JIT/dlsym path correctly.
Validation
dotnet restore -p:Platform="arm64" -p:ForceRID="osx-arm64"dotnet build --no-restore -c Release -p:Platform="arm64" -p:ForceRID="osx-arm64" -p:Version="0.7.3"dotnet restore -p:Platform="x64" -p:ForceRID="osx-x64"dotnet build --no-restore -c Release -p:Platform="x64" -p:ForceRID="osx-x64" -p:Version="0.7.3"v0.7.3 | Release: https://github.com/kkorenn/MelonLoader/actions/runs/27083213838MelonLoader.macOS.arm64.zipfromkkorenn/MelonLoader@v0.7.3and verified:MelonLoader.Bootstrap.dylibis Mach-O arm64.MLMacOSJitCopy,MLRegisterDlsymHook, andMLRealDlsym.MelonLoader.dllfornet35,net472, andnet6containsMacOSArm64NativeDetourPlatformandMLMacOSJitCopy.Both architecture builds succeeded with existing project warnings. The fork release workflow completed successfully and updated the existing
v0.7.3release assets.