Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

[iOS] Fix crash on export.

Pāvels Nadtočajevs5697c0bc04a3
diff --git a/editor/export/editor_export_platform_apple_embedded.cpp b/editor/export/editor_export_platform_apple_embedded.cpp
index 038fc630b0e..aaf2e339f34 100644
--- a/editor/export/editor_export_platform_apple_embedded.cpp
+++ b/editor/export/editor_export_platform_apple_embedded.cpp
@@ -990,11 +990,6 @@ void EditorExportPlatformAppleEmbedded::_check_xcframework_content(const String
Error EditorExportPlatformAppleEmbedded::_convert_to_framework(const String &p_source, const String &p_destination, const String &p_id) const {
print_line("Converting to .framework", p_source, " -> ", p_destination);
- Ref<DirAccess> da = DirAccess::create_for_path(p_source);
- if (da.is_null()) {
- return ERR_CANT_OPEN;
- }
-
Ref<DirAccess> filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (filesystem_da.is_null()) {
return ERR_CANT_OPEN;
@@ -1049,6 +1044,10 @@ Error EditorExportPlatformAppleEmbedded::_convert_to_framework(const String &p_s
Ref<PListNode> dpath_node = lib["DebugSymbolsPath"];
if (dpath_node.is_valid()) {
String dpath = dpath_node->get_value();
+ Ref<DirAccess> da = DirAccess::create_for_path(p_source);
+ if (da.is_null()) {
+ return ERR_CANT_OPEN;
+ }
if (da->dir_exists(p_source.path_join(library_identifier).path_join(dpath))) {
da->copy_dir(p_source.path_join(library_identifier).path_join(dpath), p_destination.path_join(library_identifier).path_join("dSYMs"));
}
@@ -1067,6 +1066,10 @@ Error EditorExportPlatformAppleEmbedded::_convert_to_framework(const String &p_s
String file_name = p_destination.get_basename().get_file();
String framework_name = file_name + ".framework";
+ Ref<DirAccess> da = DirAccess::create_for_path(p_source);
+ if (da.is_null()) {
+ return ERR_CANT_OPEN;
+ }
da->copy(p_source, p_destination.path_join(file_name));
// Performing `install_name_tool -id @rpath/{name}.framework/{name} ./{name}` on dylib
diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp
index 6e5dfb3110e..0de535784dd 100644
--- a/platform/macos/export/export_plugin.cpp
+++ b/platform/macos/export/export_plugin.cpp
@@ -1414,18 +1414,18 @@ void EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPrese
// Changes dir for the current scope, returning back to the original dir
// when scope exits
-class DirChanger {
+class DirChangerExport {
Ref<DirAccess> da;
String original_dir;
public:
- DirChanger(const Ref<DirAccess> &p_da, const String &p_dir) :
+ DirChangerExport(const Ref<DirAccess> &p_da, const String &p_dir) :
da(p_da),
original_dir(p_da->get_current_dir()) {
p_da->change_dir(p_dir);
}
- ~DirChanger() {
+ ~DirChangerExport() {
da->change_dir(original_dir);
}
};
@@ -1542,7 +1542,7 @@ Error EditorExportPlatformMacOS::_copy_dir_and_validate_arch(const Ref<EditorExp
p_to = p_to + "/";
}
- DirChanger dir_changer(p_dir_access, p_from);
+ DirChangerExport dir_changer(p_dir_access, p_from);
Error err = _copy_dir_and_validate_arch_impl(p_preset, p_dir_access, target_da, p_to, p_chmod_flags, p_copy_links);
return err;