Project detail / Swift Package · Apple-platform networking
MXray
A Swift package that turns the awkward, platform-specific work of an Xray-powered VPN into a dependency an iOS or macOS developer can integrate deliberately.
The problem
Apple's Network Extension environment is deliberately constrained: packet flow, static native libraries, geo-data, and memory all have to cooperate inside an extension that can be killed under load. The work was to make those constraints explicit and usable rather than leaving every app to rebuild the same bridge.
What shaped the build
The details are the product.
01
Make the boundary reusable
MXray exposes an XrayPacketTunnelProvider base class and an XrayBridge around NEPacketTunnelFlow, so the app-level integration begins with stable Swift entry points rather than packet handling from scratch.
02
Treat memory as a product constraint
The package includes tuning presets and a Go heap ceiling chosen for the Network Extension memory budget. That makes the most failure-prone constraint visible during integration instead of an unexplained production crash.
03
Keep the operational pieces together
Share-link parsing, asynchronous geo-file loading, latency pings, and the companion libXray-apple xcframework build sit alongside the tunnel interface—because they are all necessary parts of a shippable VPN client.
How it fits together
MXRAY / RESPONSIBILITY MAP
Host app
Configuration, profile selection, status
Network Extension
Packet Tunnel Provider + XrayBridge
Native runtime
gVisor tun engine + Xray-core