Setting environment variables and injecting libraries using Steam launch options on Mac
A working launch options example from me messing around with RED4ext on Cyberpunk for Mac:
/bin/sh -c "open --env DYLD_INSERT_LIBRARIES=\"$STEAM_DYLD_INSERT_LIBRARIES:@executable_path/../../../red4ext/RED4ext.dylib:@executable_path/../../../red4ext/FridaGadget.dylib\" --env DYLD_FORCE_FLAT_NAMESPACE=1 -nW %command% --args -fullscreen"
Which is roughly equivalent to what you would expect from writing: DYLD_INSERT_LIBRARIES=red4ext/RED4ext.dylib:red4ext/FridaGadget.dylib %command% -fullscreen (which definitely does not work)
Here's a breakdown of all the incantations:
- The first argument has to be a full path to an executable, so we use
/bin/shand pass everything else as one big string with-c %command%is automatically enclosed in single quotes ('), so the string we pass to-chas to be in double quotes ("), and any double quotes inside it have to be escaped (\")%command%refers to the .app bundle, not an executable, so we have to open it withopenrather than running it directlyopenpasses through any environment variables, but theDYLD_ones are special, so we have to set them with--env(or else they would inject libraries into theopencommand rather than the game itself)- Steam has its own libraries to inject, so we have to include
$STEAM_DYLD_INSERT_LIBRARIES(otherwise it breaks the Steam overlay and maybe other stuff too) @executable_pathrefers to the executable path inside the app bundle (in my case,Cyberpunk2077.app/Contents/MacOS/), so we need that little../../../dance to get back up to the game directory. You could also just use absolute paths if you want.- I'm not sure if the
-nWis actually necessary, but it makesopenalways launch a new instance of the app and wait until it exits, which I think is probably what Steam expects - Anything after
--argsgets passed to the game directly, ie-fullscreenis a command-line argument to the game itself
评论
?
参与讨论