Skip to content

Add macOS support#39

Open
antont wants to merge 1 commit into
MaikKlein:nextgenfrom
antont:macos-support
Open

Add macOS support#39
antont wants to merge 1 commit into
MaikKlein:nextgenfrom
antont:macos-support

Conversation

@antont

@antont antont commented Apr 2, 2026

Copy link
Copy Markdown

Summary

Adds macOS (Apple Silicon + Intel) support to the Rust plugin loader and UE C++ plugin code. Tested on macOS with UE 5.7 — the loader successfully resolves and loads the Rust plugin dylib, registers types, and the editor runs. Verified Rust gameplay code running at runtime: UKismetSystemLibrary::print_string() called from Rust tick() displays on screen during Play.

Changes:

  • RustPlugin.cpp: Return dylib extension on PLATFORM_MAC (was incorrectly returning so). Use reinterpret_cast for GetDllExport results (clang rejects static_cast from void* to function pointers).
  • unreal-rust-loader/src/lib.rs: Cross-platform rewrite — platform-gated library names/extensions, dladdr-based runtime path resolution (replaces hardcoded Windows paths), ad-hoc codesigning after hot-reload copy (macOS kills processes loading unsigned dylibs), proper error handling throughout.
  • unreal-rust-loader/Cargo.toml: Add libc dependency on Unix for dladdr/Dl_info.
  • .cargo/config.toml: Add aarch64-apple-darwin and x86_64-apple-darwin target entries.

Addresses #20.

Notes

  • The reinterpret_cast change also fixes compilation on Linux (clang strict mode) — not just macOS.
  • The loader path resolution uses a 3-tier fallback: UNREAL_RUST_TARGET_DIR env var → dladdr-derived path relative to the loader's own location → target/release/ relative fallback.
  • Hot-reload on macOS requires re-signing copied dylibs with codesign --force --sign - to avoid SIGKILL from code signature validation.
  • Not tested on Windows or Linux — the loader rewrite should be backwards-compatible (same logic, better error handling), but these platforms need verification.
  • UE 5.7 compatibility changes (build settings, example project updates) are on a separate stacked branch (ue57-compat).

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

- Fix PlatformExtensionName() to return "dylib" on macOS instead of "so"
- Replace hardcoded Windows paths in the Rust loader with platform-aware
  logic: derive root_dir from the plugin path, use UNREAL_RUST_TARGET_DIR
  env var or relative fallback for the target library path
- Use cfg-gated constants for platform-specific library extensions
  (.dll/.so/.dylib) and library names (with lib prefix on Unix)
- Guard .pdb debug symbol copy with #[cfg(target_os = "windows")]
- Add aarch64-apple-darwin and x86_64-apple-darwin Cargo targets

Closes MaikKlein#20

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant