Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dfe2df9

Browse files
committedNov 10, 2023
Merge pull request godotengine#84493 from bruvzg/gde_ios_static_fix
[iOS, GDExtension] Fix loading and exporting static libraries and xcframeworks.
2 parents a9c864d + d4d5d68 commit dfe2df9

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed
 

‎core/extension/gdextension.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,8 @@ Error GDExtensionResourceLoader::load_gdextension_resource(const String &p_path,
912912
return ERR_FILE_NOT_FOUND;
913913
}
914914

915+
bool is_static_library = library_path.ends_with(".a") || library_path.ends_with(".xcframework");
916+
915917
if (!library_path.is_resource_file() && !library_path.is_absolute_path()) {
916918
library_path = p_path.get_base_dir().path_join(library_path);
917919
}
@@ -928,7 +930,7 @@ Error GDExtensionResourceLoader::load_gdextension_resource(const String &p_path,
928930
FileAccess::get_modified_time(library_path));
929931
#endif
930932

931-
err = p_extension->open_library(library_path, entry_symbol);
933+
err = p_extension->open_library(is_static_library ? String() : library_path, entry_symbol);
932934
if (err != OK) {
933935
#if defined(WINDOWS_ENABLED) && defined(TOOLS_ENABLED)
934936
// If the DLL fails to load, make sure that temporary DLL copies are cleaned up.

‎core/os/os.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,12 @@ bool OS::has_feature(const String &p_feature) {
490490
}
491491
#endif
492492

493+
#if defined(IOS_SIMULATOR)
494+
if (p_feature == "simulator") {
495+
return true;
496+
}
497+
#endif
498+
493499
if (_check_internal_feature_support(p_feature)) {
494500
return true;
495501
}

‎doc/classes/OS.xml

+1
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@
500500
Returns [code]true[/code] if the feature for the given feature tag is supported in the currently running instance, depending on the platform, build, etc. Can be used to check whether you're currently running a debug build, on a certain platform or arch, etc. Refer to the [url=$DOCS_URL/tutorials/export/feature_tags.html]Feature Tags[/url] documentation for more details.
501501
[b]Note:[/b] Tag names are case-sensitive.
502502
[b]Note:[/b] On the web platform, one of the following additional tags is defined to indicate host platform: [code]web_android[/code], [code]web_ios[/code], [code]web_linuxbsd[/code], [code]web_macos[/code], or [code]web_windows[/code].
503+
[b]Note:[/b] On the iOS simulator, the additional [code]simulator[/code] tag is defined.
503504
</description>
504505
</method>
505506
<method name="is_debug_build" qualifiers="const">

‎editor/plugins/gdextension_export_plugin.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,20 @@ void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p
8888
archs.insert("unknown_arch"); // Not archs specified, still try to match.
8989
}
9090

91+
HashSet<String> libs_added;
92+
9193
for (const String &arch_tag : archs) {
9294
PackedStringArray tags;
9395
String library_path = GDExtension::find_extension_library(
9496
p_path, config, [features_wo_arch, arch_tag](String p_feature) { return features_wo_arch.has(p_feature) || (p_feature == arch_tag); }, &tags);
97+
if (libs_added.has(library_path)) {
98+
continue; // Universal library, already added for another arch, do not duplicate.
99+
}
95100
if (!library_path.is_empty()) {
101+
libs_added.insert(library_path);
96102
add_shared_object(library_path, tags);
97103

98-
if (p_features.has("iOS") && (library_path.ends_with(".a") || library_path.ends_with(".xcframework"))) {
104+
if (p_features.has("ios") && (library_path.ends_with(".a") || library_path.ends_with(".xcframework"))) {
99105
String additional_code = "extern void register_dynamic_symbol(char *name, void *address);\n"
100106
"extern void add_ios_init_callback(void (*cb)());\n"
101107
"\n"

‎platform/ios/detect.py

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def configure(env: "Environment"):
105105
detect_darwin_sdk_path("iossimulator", env)
106106
env.Append(ASFLAGS=["-mios-simulator-version-min=12.0"])
107107
env.Append(CCFLAGS=["-mios-simulator-version-min=12.0"])
108+
env.Append(CPPDEFINES=["IOS_SIMULATOR"])
108109
env.extra_suffix = ".simulator" + env.extra_suffix
109110
else:
110111
detect_darwin_sdk_path("ios", env)

0 commit comments

Comments
 (0)
Please sign in to comment.