summaryrefslogtreecommitdiff
path: root/modules/gdnative/gdnative.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-03 07:48:13 +0200
committerGitHub <noreply@github.com>2020-07-03 07:48:13 +0200
commit64aa25b2e59741c392b7ab4703e5503286db2347 (patch)
tree6672ba66248105d9ceff00c9eddc419689d769ac /modules/gdnative/gdnative.cpp
parent670d3a616cc961a6cb7886e65409744013c2fe1d (diff)
parent294416c84cc4d877a410af7692c1119436b1f313 (diff)
Merge pull request #40050 from naithar/feature/ios-gdnative-master-2
[4.0] Add support of iOS's dynamic libraries to GDNative
Diffstat (limited to 'modules/gdnative/gdnative.cpp')
-rw-r--r--modules/gdnative/gdnative.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 3d747ba41e..bb2da70c3a 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -291,8 +291,26 @@ bool GDNative::initialize() {
return false;
}
#ifdef IPHONE_ENABLED
- // on iOS we use static linking
+ // On iOS we use static linking by default.
String path = "";
+
+ // On iOS dylibs is not allowed, but can be replaced with .framework or .xcframework.
+ // If they are used, we can run dlopen on them.
+ // They should be located under Frameworks directory, so we need to replace library path.
+ if (!lib_path.ends_with(".a")) {
+ path = ProjectSettings::get_singleton()->globalize_path(lib_path);
+
+ if (!FileAccess::exists(path)) {
+ String lib_name = lib_path.get_basename().get_file();
+ String framework_path_format = "Frameworks/$name.framework/$name";
+
+ Dictionary format_dict;
+ format_dict["name"] = lib_name;
+ String framework_path = framework_path_format.format(format_dict, "$_");
+
+ path = OS::get_singleton()->get_executable_path().get_base_dir().plus_file(framework_path);
+ }
+ }
#elif defined(ANDROID_ENABLED)
// On Android dynamic libraries are located separately from resource assets,
// we should pass library name to dlopen(). The library name is flattened