Quick answer: dyld, the macOS dynamic linker, could not load a library your executable depends on, so it ended the process before main. With an @rpath/ name, the usual cause is that the library is not inside the app bundle, or the executable has no LC_RPATH entry pointing at the folder it is in. Put the library in Contents/Frameworks, give it the install name @rpath/libname.dylib, add the run path @executable_path/../Frameworks to the executable, then sign the app again. Check the result with otool -L and otool -l.
A player double-clicks the game and gets “MyGame quit unexpectedly.” Nothing of yours ran. dyld read the list of libraries recorded in the executable, failed to load one of them, and aborted the launch. The crash report says which library and, on current macOS, every path dyld tried and why each one failed. It works on your Mac because the library exists there, in a Homebrew folder or a build directory that no player has. This guide explains how dyld turns a name like @rpath/libfoo.dylib into a file, how to read the Reason: line, and how to build a bundle that carries its own libraries and passes code signing.
- The exact error
- How dyld finds a library
- Reading the Reason line
- How to find which case you have
- Fix 1: build the library and the game for the bundle
- Fix 2: patch binaries you cannot relink
- Fix 3: the library is found but refused
- Engine and SDK notes
- What players can do, and how to confirm the fix
- What Bugnet sees of a dyld failure
- Related guides
- Frequently asked questions
The exact error
In a crash report on macOS 12 and later, the relevant lines are near the top:
Termination Reason: Namespace DYLD, Code 1 Library missing
Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2
Referenced from: /Applications/MyGame.app/Contents/MacOS/MyGame
Reason: tried: '/Applications/MyGame.app/Contents/MacOS/../Frameworks/SDL2.framework/Versions/A/SDL2' (no such file), '/Library/Frameworks/SDL2.framework/Versions/A/SDL2' (no such file), '/System/Library/Frameworks/SDL2.framework/Versions/A/SDL2' (no such file)
(terminated at launch; ignore backtrace)
The crash reporter often cuts the Reason: line short. Run the executable inside the bundle from Terminal to get all of it:
% /Applications/MyGame.app/Contents/MacOS/MyGame
dyld[79650]: Library not loaded: @rpath/libfoo.dylib
Referenced from: /Applications/MyGame.app/Contents/MacOS/MyGame
Reason: tried: '/Applications/MyGame.app/Contents/MacOS/../Frameworks/libfoo.dylib' (no such file), '/usr/local/lib/libfoo.dylib' (no such file), '/usr/lib/libfoo.dylib' (no such file)
zsh: abort /Applications/MyGame.app/Contents/MacOS/MyGame
Recent releases print a UUID in angle brackets after Referenced from:, and the exact layout changes between macOS versions. macOS 11 and earlier did not list the paths at all:
dyld: Library not loaded: @rpath/libfoo.dylib
Referenced from: /Applications/MyGame.app/Contents/MacOS/MyGame
Reason: image not found
Three lines carry the information. Library not loaded is the name dyld was asked for. Referenced from is the binary that asked, which is not always your main executable: it can be one of your libraries looking for its own dependency. Reason is a list of attempts, each with the cause in parentheses.
How dyld finds a library
Every dynamic library has an install name stored inside it, in a load command called LC_ID_DYLIB. When you link your game against the library, the linker copies that install name into your executable as an LC_LOAD_DYLIB entry. At launch dyld loads exactly what each entry says. Where you put the file afterwards plays no part unless the name allows for it. The path in the error was chosen when the library was built.
An install name is either an absolute path or starts with one of three placeholders:
| Prefix | dyld replaces it with | Typical use |
|---|---|---|
| (absolute path) | Nothing. The file must exist at that exact path. | System libraries in /usr/lib. Also what Homebrew libraries have, which is the problem. |
@executable_path/ | The folder containing the process’s main executable, Contents/MacOS in an app | A library used only by one app |
@loader_path/ | The folder containing the binary that holds this load command | A plug-in or library finding files next to itself |
@rpath/ | Each entry of the run path list in turn, until a loadable file is found | Libraries meant to be embedded in any app |
The run path list is built from LC_RPATH load commands in the binaries along the loading chain, starting with the main executable. Each entry is a folder, usually written with @executable_path or @loader_path so it moves with the app. So @rpath/libfoo.dylib with the run path @executable_path/../Frameworks means MyGame.app/Contents/Frameworks/libfoo.dylib, wherever the app is installed.
That is the layout to aim for:
MyGame.app/Contents/MacOS/MyGame LC_RPATH @executable_path/../Frameworks
MyGame.app/Contents/Frameworks/libfoo.dylib install name @rpath/libfoo.dylib
MyGame.app/Contents/Frameworks/SDL2.framework install name @rpath/SDL2.framework/Versions/A/SDL2
Frameworks and loose dylibs both belong in Contents/Frameworks. Do not put code in Contents/Resources, where the signing machinery expects data. An @rpath error therefore has two plain causes: no run path leads to the folder, or the folder does not contain the file.
Reading the Reason line
| Text in the Reason | What it means | Fix |
|---|---|---|
(no such file) for every path, or image not found | The library is not in the bundle, or no run path points at the folder it is in | Fix 1 or Fix 2 |
no LC_RPATH's found | The name starts with @rpath/ and the binary has no run path at all | Add the run path (Fix 1 or Fix 2) |
A tried path under /opt/homebrew, /usr/local or /Users/yourname | The install name is an absolute path from your build machine | Fix 2 |
mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64') | The file was found but has no slice for the running architecture | Fix 3 |
not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs | The hardened runtime’s library validation refused a library signed by a different team | Fix 3 |
mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. | The library carries no usable signature, or was built with tools too old for the hardened runtime | Fix 3 |
The last tried paths are often /usr/local/lib and /usr/lib. Those are dyld’s fallback locations, not a hint about where the library should be. According to the dyld manual page, binaries built since fall 2023 have no default fallback path, so a newer build shows a shorter list.
How to find which case you have
List what the executable asks for:
otool -L MyGame.app/Contents/MacOS/MyGame
MyGame.app/Contents/MacOS/MyGame:
@rpath/libfoo.dylib (compatibility version 1.0.0, current version 1.0.0)
/opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib (compatibility version ..., current version ...)
/usr/lib/libc++.1.dylib (compatibility version ..., current version ...)
/usr/lib/libSystem.B.dylib (compatibility version ..., current version ...)
Lines under /usr/lib and /System/Library are the operating system and are fine. The second line is a library that exists only where Homebrew installed it. The first needs a run path, so list those:
otool -l MyGame.app/Contents/MacOS/MyGame | grep -A2 LC_RPATH
cmd LC_RPATH
cmdsize 48
path @executable_path/../Frameworks (offset 12)
No output means no run paths. A path such as /Users/ci/build/lib means the linker recorded your build folder. To see the install name a library itself carries, which is what the next link will copy:
otool -D MyGame.app/Contents/Frameworks/libfoo.dylib
Then check every binary in the bundle, because a bundled library can have a broken dependency of its own. This prints each reference to a path that will not exist on a player’s Mac:
find MyGame.app -type f -exec sh -c \
'file -b "$1" | grep -q "Mach-O" && otool -L "$1" | grep -E "/opt/homebrew|/usr/local|/Users/" && echo " in: $1"' _ {} \;
For a narrated launch, set DYLD_PRINT_SEARCHING=1 before running the executable from Terminal. dyld then prints every file system path it checks. Do this on the development build: a binary signed with the hardened runtime may ignore dyld environment variables.
Fix 1: build the library and the game for the bundle
When you control the build, set both halves at link time. The library gets an @rpath install name and the game gets a run path:
clang -dynamiclib foo.c -o libfoo.dylib -install_name @rpath/libfoo.dylib
clang main.c -o MyGame -L. -lfoo -Wl,-rpath,@executable_path/../Frameworks
Then copy libfoo.dylib into MyGame.app/Contents/Frameworks as part of packaging. In Xcode the same two settings are Dynamic Library Install Name Base (@rpath) on the library target and Runpath Search Paths (@executable_path/../Frameworks) on the app target, and the library has to be listed under Frameworks, Libraries, and Embedded Content with Embed & Sign. Linking without embedding is the classic way to get this crash from an Xcode project. In CMake:
set_target_properties(MyGame PROPERTIES
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH "@executable_path/../Frameworks")
A library that loads another bundled library needs its own way to find it, because the reference is resolved from the library’s load commands. Either give both the @rpath form, which works through the executable’s run path, or give the first library a run path of @loader_path.
Fix 2: patch binaries you cannot relink
install_name_tool edits load commands in place. To bring a Homebrew library into the bundle and repoint the game at it:
APP=MyGame.app
mkdir -p "$APP/Contents/Frameworks"
cp /opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib "$APP/Contents/Frameworks/"
# 1. change the library's own install name
install_name_tool -id @rpath/libSDL2-2.0.0.dylib "$APP/Contents/Frameworks/libSDL2-2.0.0.dylib"
# 2. change the reference recorded in the executable
install_name_tool -change /opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib \
@rpath/libSDL2-2.0.0.dylib "$APP/Contents/MacOS/MyGame"
# 3. add the run path, if otool showed none
install_name_tool -add_rpath @executable_path/../Frameworks "$APP/Contents/MacOS/MyGame"
-add_rpath stops with an error when the binary already has that path; use -rpath old new to replace an entry and -delete_rpath to remove one. If the tool reports that the larger load commands do not fit, the binary was linked without spare header room and has to be relinked with -Wl,-headerpad_max_install_names.
Run otool -L on the copied library as well. Homebrew libraries depend on other Homebrew libraries by absolute path, and each one needs the same three steps. Be aware of what you are copying: a Homebrew bottle is built for the architecture and macOS version of the machine that installed it, so it is single-architecture and may not load on an older macOS. For a release, prefer the vendor’s universal build or compile the library yourself with a deployment target.
Every edit changes the file, so it invalidates the code signature. install_name_tool says so:
install_name_tool: warning: changes being made to the file will invalidate the code signature in: MyGame.app/Contents/MacOS/MyGame
On Apple silicon a binary with a broken signature is killed at launch, so re-sign before you test. For a local test an ad-hoc signature is enough; for release, sign with your Developer ID, libraries first and the app last:
# local testing
codesign --force --sign - "$APP/Contents/Frameworks/libSDL2-2.0.0.dylib"
codesign --force --sign - "$APP"
# release
codesign --force --options runtime --timestamp \
--sign "Developer ID Application: Your Studio (TEAMID)" "$APP/Contents/Frameworks/libSDL2-2.0.0.dylib"
codesign --force --options runtime --timestamp --entitlements MyGame.entitlements \
--sign "Developer ID Application: Your Studio (TEAMID)" "$APP"
A re-signed app is a new artifact for Apple’s notary service, so notarize again. Fixing Mac notarization errors covers that step and what its log messages mean.
Fix 3: the library is found but refused
Wrong architecture
Run lipo -archs on the library and on the executable. A universal game needs every library to contain both x86_64 and arm64. Build the missing slice and merge the two files with lipo -create; “Bad CPU type in executable” has the commands and the engine settings.
Different Team IDs
The hardened runtime, which notarization requires, turns on library validation: a process may load only code signed by Apple or by the same team as its main executable. Compare the two:
codesign -d -vvv MyGame.app 2>&1 | grep TeamIdentifier
codesign -d -vvv MyGame.app/Contents/Frameworks/libfoo.dylib 2>&1 | grep TeamIdentifier
If the library ships inside your app, re-sign it with your own identity, even when a third party built it. That is Apple’s guidance and it keeps library validation on. Only when the game must load code you do not ship (mods, user-installed plug-ins, the Steam overlay) should the main executable opt out with an entitlement:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
Entitlements go on executables only. Libraries and frameworks inherit them from the process that loads them, so sign those without --entitlements.
Unsigned library
Sign it with the release command above. If the message persists for a very old prebuilt library, it predates what the hardened runtime accepts and has to be rebuilt with current tools.
Engine and SDK notes
- Unity. Native plug-ins are copied into the built app (the
Contents/PlugInsfolder) and loaded on demand at the first P/Invoke call, so a missing plug-in is aDllNotFoundExceptionin~/Library/Logs/<Company>/<Product>/Player.log, not a crash at launch. The dyld case appears when a plug-in links a second dylib: put that file beside the plug-in and give the plug-in a run path withinstall_name_tool -add_rpath @loader_path. - Steamworks. The SDK’s
libsteam_api.dylibhas the install name@loader_path/libsteam_api.dylib, so a game that links it directly looks for it in the same folder as the binary that references it. Either ship it there, or move it toContents/Frameworksand runinstall_name_tool -change @loader_path/libsteam_api.dylib @rpath/libsteam_api.dylibon the executable. Steamworks’ documentation also asks for thedisable-library-validationandallow-dyld-environment-variablesentitlements so the overlay can be loaded. - SDL. The official
SDL2.frameworkuses the install name@rpath/SDL2.framework/Versions/A/SDL2, which is why this error so often names it. Embed the framework inContents/Frameworksand add the run path. A game linked against Homebrew’s SDL has an absolute path instead and needs Fix 2. - Godot. GDExtension libraries are opened at run time, so a failure is logged as
Can't open dynamic libraryfollowed by dyld’s reason, and the game keeps running without the extension. List extra libraries in the[dependencies]section of the.gdextensionfile so the exporter copies them.
What players can do, and how to confirm the fix
There is very little a player can do about a library that was never shipped. Ask for two things. First, verify the game files (in Steam: Properties > Installed Files > Verify integrity of game files), which restores a library that was deleted after installation. Second, send the top of the crash report: click Report… in the “quit unexpectedly” dialog and copy the text down to the Reason: line, or find the report later in the Console app under Crash Reports. Do not ask players to install Homebrew packages to fill the gap. It works only on a matching architecture and it hides the bug.
To confirm the fix, test on a Mac that is not your build machine. Homebrew is installed system-wide, so a second user account on the same Mac proves nothing, and a CI runner that has Homebrew is not a clean machine either. On the test Mac:
otool -L MyGame.app/Contents/MacOS/MyGame
codesign --verify --deep --strict --verbose=2 MyGame.app
Every dependency should start with @rpath/, @executable_path/, @loader_path/, /usr/lib/ or /System/Library/, and the signature should verify. Launch the app from /Applications and again from the Downloads folder to prove nothing depends on its location. For a universal build, run it once more with arch -x86_64 on Apple silicon so the Intel slices of every library get loaded too.
What Bugnet sees of a dyld failure
dyld ends the process before the first line of the game runs, so no SDK inside it can report the launch, and Bugnet is no exception. The crash report exists only on the player’s Mac. Two nearby cases do reach you. A library opened later, on demand, fails inside a running game: the Unity SDK files the resulting DllNotFoundException automatically with its stack trace, recent log lines, macOS version and CPU, and repeats stack into one entry with an occurrence count. The CPU field also tells you whether the reports come from Apple silicon or Intel, which is the first question for an architecture mismatch.
For the launch crash itself, add a known-issue entry to the project’s public tracker titled with the “Library not loaded” line. Players who search the message find it, and it is the place to say which build contains the fix.
Related guides
- How to Fix Mac Notarization Errors for Your Game (notarytool “status: Invalid”)
- How to Fix “Bad CPU type in executable” for Your Mac Game
- How to Fix “is damaged and can’t be opened. You should move it to the Trash” for Your Mac Game
- Where macOS Stores Crash Reports for Your Game (.ips Files) and How to Read Them
- How to Fix “DllNotFoundException: Unable to load DLL” in Unity
Frequently asked questions
What does dyld: Library not loaded: @rpath mean?
The macOS dynamic linker could not load a library the game's executable depends on, so it ended the process before any game code ran. The @rpath prefix means the library is looked up in the folders listed in the binary's LC_RPATH entries. Either no entry points at the folder holding the library or the file is not in the app bundle.
Where should dylibs and frameworks go inside a Mac app bundle?
Put them in Contents/Frameworks. Give each library an install name of the form @rpath/libname.dylib and add the run path @executable_path/../Frameworks to the main executable so the lookup follows the app wherever it is installed.
Why does my Mac game launch on my machine but crash on a player's Mac?
Your Mac has the library at the path recorded in the executable, usually a Homebrew folder such as /opt/homebrew or a build directory under /Users. Players do not have those paths. Run otool -L on the executable and look for any dependency outside /usr/lib, /System/Library and the @rpath, @executable_path or @loader_path forms.
What is the difference between @rpath, @executable_path and @loader_path?
@executable_path is the folder that contains the process's main executable. @loader_path is the folder that contains the binary doing the loading, which can be a library or plug-in. @rpath is replaced by each folder in the run path list in turn until the library is found.
Do I need to sign the app again after using install_name_tool?
Yes. Editing a load command changes the file and invalidates its code signature, and on Apple silicon a binary with a broken signature is killed at launch. Sign the changed libraries first and the app last, then notarize the new build.
Run otool -L on every binary in the bundle before each release. Any dependency path that starts with /opt/homebrew, /usr/local or /Users will fail on a player's Mac.