diff options
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/export/export_plugin.cpp | 45 | ||||
-rw-r--r-- | platform/ios/export/export_plugin.h | 1 | ||||
-rw-r--r-- | platform/ios/os_ios.mm | 9 |
3 files changed, 42 insertions, 13 deletions
diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index 3cae85ea55..6bc3241425 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -1077,14 +1077,15 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String return ERR_FILE_NOT_FOUND; } - String base_dir = p_asset.get_base_dir().replace("res://", ""); + String base_dir = p_asset.get_base_dir().replace("res://", "").replace(".godot/mono/temp/bin/", ""); + String asset = p_asset.ends_with("/") ? p_asset.left(p_asset.length() - 1) : p_asset; String destination_dir; String destination; String asset_path; bool create_framework = false; - if (p_is_framework && p_asset.ends_with(".dylib")) { + if (p_is_framework && asset.ends_with(".dylib")) { // For iOS we need to turn .dylib into .framework // to be able to send application to AppStore asset_path = String("dylibs").path_join(base_dir); @@ -1103,7 +1104,7 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String destination_dir = p_out_dir.path_join(asset_path); destination = destination_dir.path_join(file_name); create_framework = true; - } else if (p_is_framework && (p_asset.ends_with(".framework") || p_asset.ends_with(".xcframework"))) { + } else if (p_is_framework && (asset.ends_with(".framework") || asset.ends_with(".xcframework"))) { asset_path = String("dylibs").path_join(base_dir); String file_name; @@ -1147,6 +1148,9 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String if (err) { return err; } + if (asset_path.ends_with("/")) { + asset_path = asset_path.left(asset_path.length() - 1); + } IOSExportAsset exported_asset = { binary_name.path_join(asset_path), p_is_framework, p_should_embed }; r_exported_assets.push_back(exported_asset); @@ -1213,13 +1217,16 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets) { for (int f_idx = 0; f_idx < p_assets.size(); ++f_idx) { String asset = p_assets[f_idx]; - if (!asset.begins_with("res://")) { + if (asset.begins_with("res://")) { + Error err = _copy_asset(p_out_dir, asset, nullptr, p_is_framework, p_should_embed, r_exported_assets); + ERR_FAIL_COND_V(err, err); + } else if (ProjectSettings::get_singleton()->localize_path(asset).begins_with("res://")) { + Error err = _copy_asset(p_out_dir, ProjectSettings::get_singleton()->localize_path(asset), nullptr, p_is_framework, p_should_embed, r_exported_assets); + ERR_FAIL_COND_V(err, err); + } else { // either SDK-builtin or already a part of the export template IOSExportAsset exported_asset = { asset, p_is_framework, p_should_embed }; r_exported_assets.push_back(exported_asset); - } else { - Error err = _copy_asset(p_out_dir, asset, nullptr, p_is_framework, p_should_embed, r_exported_assets); - ERR_FAIL_COND_V(err, err); } } @@ -2064,6 +2071,28 @@ bool EditorExportPlatformIOS::is_package_name_valid(const String &p_package, Str } #ifdef MACOS_ENABLED +bool EditorExportPlatformIOS::_check_xcode_install() { + static bool xcode_found = false; + if (!xcode_found) { + Vector<String> mdfind_paths; + List<String> mdfind_args; + mdfind_args.push_back("kMDItemCFBundleIdentifier=com.apple.dt.Xcode"); + + String output; + Error err = OS::get_singleton()->execute("mdfind", mdfind_args, &output); + if (err == OK) { + mdfind_paths = output.split("\n"); + } + for (const String &found_path : mdfind_paths) { + xcode_found = !found_path.is_empty() && DirAccess::dir_exists_absolute(found_path.strip_edges()); + if (xcode_found) { + break; + } + } + } + return xcode_found; +} + void EditorExportPlatformIOS::_check_for_changes_poll_thread(void *ud) { EditorExportPlatformIOS *ea = static_cast<EditorExportPlatformIOS *>(ud); @@ -2131,7 +2160,7 @@ void EditorExportPlatformIOS::_check_for_changes_poll_thread(void *ud) { } // Enum simulators - if (FileAccess::exists("/usr/bin/xcrun") || FileAccess::exists("/bin/xcrun")) { + if (_check_xcode_install() && (FileAccess::exists("/usr/bin/xcrun") || FileAccess::exists("/bin/xcrun"))) { String devices; List<String> args; args.push_back("simctl"); diff --git a/platform/ios/export/export_plugin.h b/platform/ios/export/export_plugin.h index 27a4d73fcd..951017ddae 100644 --- a/platform/ios/export/export_plugin.h +++ b/platform/ios/export/export_plugin.h @@ -81,6 +81,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform { Thread check_for_changes_thread; SafeFlag quit_request; + static bool _check_xcode_install(); static void _check_for_changes_poll_thread(void *ud); #endif diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm index 68e6d4c934..16ac3acbec 100644 --- a/platform/ios/os_ios.mm +++ b/platform/ios/os_ios.mm @@ -72,16 +72,15 @@ HashMap<String, void *> OS_IOS::dynamic_symbol_lookup_table; void add_ios_init_callback(init_callback cb) { if (ios_init_callbacks_count == ios_init_callbacks_capacity) { - void *new_ptr = realloc(ios_init_callbacks, sizeof(cb) * 32); + void *new_ptr = realloc(ios_init_callbacks, sizeof(cb) * (ios_init_callbacks_capacity + 32)); if (new_ptr) { ios_init_callbacks = (init_callback *)(new_ptr); ios_init_callbacks_capacity += 32; + } else { + ERR_FAIL_MSG("Unable to allocate memory for extension callbacks."); } } - if (ios_init_callbacks_capacity > ios_init_callbacks_count) { - ios_init_callbacks[ios_init_callbacks_count] = cb; - ++ios_init_callbacks_count; - } + ios_init_callbacks[ios_init_callbacks_count++] = cb; } void register_dynamic_symbol(char *name, void *address) { |