Merge pull request #112784 from migueldeicaza/fix_dynamic_xcframework_loading

iOS: Fix loading of xcframework dynamic libraries.
This commit is contained in:
Thaddeus Crews
2025-11-18 08:25:45 -06:00
3 changed files with 20 additions and 7 deletions

View File

@ -279,6 +279,11 @@ Error OS_AppleEmbedded::open_dynamic_library(const String &p_path, void *&p_libr
path = get_framework_executable(get_executable_path().get_base_dir().path_join(p_path.get_file().get_basename() + ".framework"));
}
if (!FileAccess::exists(path)) {
// Load .dylib from within the executable path.
path = get_framework_executable(get_executable_path().get_base_dir().path_join(p_path.get_file().get_basename() + ".dylib"));
}
if (!FileAccess::exists(path)) {
// Load .dylib or framework from a standard iOS location.
path = get_framework_executable(get_executable_path().get_base_dir().path_join("Frameworks").path_join(p_path.get_file()));
@ -289,8 +294,16 @@ Error OS_AppleEmbedded::open_dynamic_library(const String &p_path, void *&p_libr
path = get_framework_executable(get_executable_path().get_base_dir().path_join("Frameworks").path_join(p_path.get_file().get_basename() + ".framework"));
}
ERR_FAIL_COND_V(!FileAccess::exists(path), ERR_FILE_NOT_FOUND);
if (!FileAccess::exists(path)) {
// Load .dylib from a standard iOS location.
path = get_framework_executable(get_executable_path().get_base_dir().path_join("Frameworks").path_join(p_path.get_file().get_basename() + ".dylib"));
}
if (!FileAccess::exists(path) && (p_path.ends_with(".a") || p_path.ends_with(".xcframework"))) {
path = String(); // Try loading static library.
} else {
ERR_FAIL_COND_V(!FileAccess::exists(path), ERR_FILE_NOT_FOUND);
}
p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
ERR_FAIL_NULL_V_MSG(p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror()));