diff --git a/renderdoc/os/posix/apple/apple_helpers.mm b/renderdoc/os/posix/apple/apple_helpers.mm index 3d1f87332..8cc4c494c 100644 --- a/renderdoc/os/posix/apple/apple_helpers.mm +++ b/renderdoc/os/posix/apple/apple_helpers.mm @@ -22,6 +22,8 @@ * THE SOFTWARE. ******************************************************************************/ +#include "api/replay/rdcstr.h" + #import #define MAX_COUNT_KEYS (65536) @@ -56,3 +58,13 @@ bool apple_IsKeyPressed(int appleKeyCode) { return s_keysPressed[appleKeyCode]; } + +rdcstr apple_GetExecutablePathFromAppBundle(const char *appBundlePath) +{ + NSString *path = [NSString stringWithCString:appBundlePath encoding:NSUTF8StringEncoding]; + NSBundle *nsBundle = [NSBundle bundleWithPath:path]; + NSString *executablePath = nsBundle.executablePath; + + rdcstr result([executablePath cStringUsingEncoding:NSUTF8StringEncoding]); + return result; +} diff --git a/renderdoc/os/posix/posix_process.cpp b/renderdoc/os/posix/posix_process.cpp index 179be1957..c86703eb2 100644 --- a/renderdoc/os/posix/posix_process.cpp +++ b/renderdoc/os/posix/posix_process.cpp @@ -41,6 +41,9 @@ #include "os/os_specific.h" #include "strings/string_utils.h" +// defined in apple_helpers.mm +extern rdcstr apple_GetExecutablePathFromAppBundle(const char *appBundlePath); + // defined in foo/foo_process.cpp char **GetCurrentEnvironment(); int GetIdentPort(pid_t childPid); @@ -536,8 +539,7 @@ static pid_t RunProcess(rdcstr appName, rdcstr workDir, const rdcstr &cmdLine, c #if ENABLED(RDOC_APPLE) if(appName.size() > 5 && appName.endsWith(".app")) { - rdcstr realAppName = appName + "/Contents/MacOS/" + get_basename(appName); - realAppName.erase(realAppName.size() - 4, ~0U); + rdcstr realAppName = apple_GetExecutablePathFromAppBundle(appName.c_str()); if(FileIO::exists(realAppName)) {