[macOS] Harmony patch fails with "mprotect returned EACCES" - System Integrity Protection blocks mod
I’m trying to use the mod Choose Your Fighter on macOS, but the mod fails to apply Harmony patches with the following error:
System.TypeInitializationException: The type initializer for 'HarmonyLib.HarmonySharedState' threw an exception. ---> System.Exception: mprotect returned EACCES
at MonoMod.RuntimeDetour.Platforms.DetourNativeMonoPosixPlatform.SetMemPerms (System.IntPtr start, System.UInt64 len, ...)
...
As far as I resarched it, this error indicates that macOS is preventing the mod from changing memory protection flags, which is necessary for Harmony and MonoMod to patch native code at runtime.
Environment
- OS: macOS [15.5 (24F74)]
- Mod version: latest
Steps to reproduce
- Install the mod via Steam Workshop / manual install.
- Launch the game on macOS.
- Observe the error printed in logs and failure to patch.
Additional info
- I have granted Full Disk Access to the game in macOS System Settings but the error persists.
- Disabling System Integrity Protection (SIP) resolves the issue but is not recommended due to security concerns.
- This is a known limitation on macOS when using Harmony and MonoMod runtime detouring.
- Possible workarounds:
- Avoid mods relying on Harmony/MonoMod native patching on macOS.
- Provide a macOS-compatible version using reflection-based patching if possible.
Request
Could you please consider:
- Documenting this macOS limitation for users.
- Providing guidance or macOS-safe alternatives for Harmony patches.
- Any potential fixes or mitigations specific to macOS?
Thank you for your work on this mod!