iOS: Fix loading of xcframework dynamic libraries.

The logic used to determine whether to invoke the in-memory registration or to
delegate the loading of a library is incorrect for xcframework packages - as
these can contain either static or dynamic libraries.

This change instead lets the operating system handle the library request, and if
it fails, it attempts to load from the internal registry.

With this change, xcframeworks containing dynamic libraries work without
workarounds on iOS.

With an additional fallback case courtesy of @bruvzg

This fixes https://github.com/godotengine/godot/issues/112783
This commit is contained in:
Miguel de Icaza 2025-11-14 15:56:11 -05:00
parent bd2ca13c6f
commit b1465d6af0
3 changed files with 20 additions and 7 deletions

View file

@ -195,9 +195,13 @@ Error GDExtensionLibraryLoader::open_library(const String &p_path) {
&abs_dependencies_paths, // library_dependencies
};
err = OS::get_singleton()->open_dynamic_library(is_static_library ? String() : abs_path, library, &data);
// Apple has a complex lookup system which goes beyond looking up the filename, so we try that first.
err = OS::get_singleton()->open_dynamic_library(abs_path, library, &data);
if (err != OK) {
return err;
err = OS::get_singleton()->open_dynamic_library(String(), library, &data);
if (err != OK) {
return err;
}
}
return OK;
@ -361,8 +365,6 @@ Error GDExtensionLibraryLoader::parse_gdextension_file(const String &p_path) {
return ERR_FILE_NOT_FOUND;
}
is_static_library = library_path.ends_with(".a") || library_path.ends_with(".xcframework");
if (!library_path.is_resource_file() && !library_path.is_absolute_path()) {
library_path = p_path.get_base_dir().path_join(library_path);
}

View file

@ -49,8 +49,6 @@ private:
String library_path;
String entry_symbol;
bool is_static_library = false;
#ifdef TOOLS_ENABLED
bool is_reloadable = false;
#endif