From 9b7713cf92582cf56c4f79116001c33d1e6e655f Mon Sep 17 00:00:00 2001 From: Nikita Fediuchin Date: Thu, 26 May 2022 09:27:39 +0300 Subject: [PATCH] Cocoa: Fix search path for private Vulkan loader According to both Apple and LunarG, a private copy of the macOS Vulkan loader libvulkan.1.dylib should be placed in the Frameworks directory of the bundle and not its main executable directory. This commit updates the dynamic loading path accordingly. Fixes #2113 Closes #2120 --- src/cocoa_init.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 6bc6496a..48f67690 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -460,11 +460,18 @@ void* _glfwLoadLocalVulkanLoaderCocoa(void) if (!bundle) return NULL; - CFURLRef url = - CFBundleCopyAuxiliaryExecutableURL(bundle, CFSTR("libvulkan.1.dylib")); - if (!url) + CFURLRef frameworksUrl = CFBundleCopyPrivateFrameworksURL(bundle); + if (!frameworksUrl) return NULL; + CFURLRef url = CFURLCreateCopyAppendingPathComponent( + kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false); + if (!url) + { + CFRelease(frameworksUrl); + return NULL; + } + char path[PATH_MAX]; void* handle = NULL; @@ -472,6 +479,7 @@ void* _glfwLoadLocalVulkanLoaderCocoa(void) handle = _glfwPlatformLoadModule(path); CFRelease(url); + CFRelease(frameworksUrl); return handle; }