| 1 | /**************************************************************************/ |
| 2 | /* export_plugin.cpp */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #include "export_plugin.h" |
| 32 | |
| 33 | #include "logo_svg.gen.h" |
| 34 | #include "run_icon_svg.gen.h" |
| 35 | |
| 36 | #include "editor/editor_node.h" |
| 37 | |
| 38 | Vector<String> EditorExportPlatformIOS::device_types({ "iPhone", "iPad" }); |
| 39 | |
| 40 | void EditorExportPlatformIOS::initialize() { |
| 41 | if (EditorNode::get_singleton()) { |
| 42 | EditorExportPlatformAppleEmbedded::_initialize(_ios_logo_svg, _ios_run_icon_svg); |
| 43 | #ifdef MACOS_ENABLED |
| 44 | _start_remote_device_poller_thread(); |
| 45 | #endif |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | EditorExportPlatformIOS::~EditorExportPlatformIOS() { |
| 50 | #ifdef MACOS_ENABLED |
| 51 | _stop_remote_device_poller_thread(); |
| 52 | #endif |
| 53 | } |
| 54 | |
| 55 | void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) const { |
| 56 | EditorExportPlatformAppleEmbedded::get_export_options(r_options); |
| 57 | |
| 58 | r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/targeted_device_family", PROPERTY_HINT_ENUM, "iPhone,iPad,iPhone & iPad"), 2)); |
| 59 | r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/min_ios_version"), get_minimum_deployment_target())); |
| 60 | |
| 61 | r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "storyboard/image_scale_mode", PROPERTY_HINT_ENUM, "Same as Logo,Center,Scale to Fit,Scale to Fill,Scale"), 0)); |
| 62 | r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "storyboard/custom_image@2x", PROPERTY_HINT_FILE_PATH, "*.png,*.jpg,*.jpeg"), "")); |
| 63 | r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "storyboard/custom_image@3x", PROPERTY_HINT_FILE_PATH, "*.png,*.jpg,*.jpeg"), "")); |
| 64 | r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "storyboard/use_custom_bg_color"), false)); |
| 65 | r_options->push_back(ExportOption(PropertyInfo(Variant::COLOR, "storyboard/custom_bg_color"), Color())); |
| 66 | } |
| 67 | |
| 68 | bool EditorExportPlatformIOS::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const { |
| 69 | bool valid = EditorExportPlatformAppleEmbedded::has_valid_export_configuration(p_preset, r_error, r_missing_templates, p_debug); |
| 70 | |
| 71 | String err; |
| 72 | String rendering_method = get_project_setting(p_preset, "rendering/renderer/rendering_method.mobile"); |
| 73 | String rendering_driver = get_project_setting(p_preset, "rendering/rendering_device/driver." + get_platform_name()); |
| 74 | if ((rendering_method == "forward_plus" || rendering_method == "mobile") && rendering_driver == "metal") { |
| 75 | float version = p_preset->get("application/min_ios_version").operator String().to_float(); |
| 76 | if (version < 14.0) { |
| 77 | err += TTR("Metal renderer require iOS 14+.") + "\n"; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | if (!err.is_empty()) { |
| 82 | if (!r_error.is_empty()) { |
| 83 | r_error += err; |
| 84 | } else { |
| 85 | r_error = err; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | return valid; |
| 90 | } |
| 91 | |
| 92 | HashMap<String, Variant> EditorExportPlatformIOS::get_custom_project_settings(const Ref<EditorExportPreset> &p_preset) const { |
| 93 | HashMap<String, Variant> settings; |
| 94 | |
| 95 | int image_scale_mode = p_preset->get("storyboard/image_scale_mode"); |
| 96 | String value; |
| 97 | |
| 98 | switch (image_scale_mode) { |
| 99 | case 0: { |
| 100 | String logo_path = get_project_setting(p_preset, "application/boot_splash/image"); |
| 101 | RenderingServer::SplashStretchMode stretch_mode = get_project_setting(p_preset, "application/boot_splash/stretch_mode"); |
| 102 | // If custom logo is not specified, Godot does not scale default one, so we should do the same. |
| 103 | if (logo_path.is_empty()) { |
| 104 | value = "center"; |
| 105 | } else { |
| 106 | switch (stretch_mode) { |
| 107 | case RenderingServer::SplashStretchMode::SPLASH_STRETCH_MODE_DISABLED: { |
| 108 | value = "center"; |
| 109 | } break; |
| 110 | case RenderingServer::SplashStretchMode::SPLASH_STRETCH_MODE_KEEP: { |
| 111 | value = "scaleAspectFit"; |
| 112 | } break; |
| 113 | case RenderingServer::SplashStretchMode::SPLASH_STRETCH_MODE_KEEP_WIDTH: { |
| 114 | value = "scaleAspectFit"; |
| 115 | } break; |
| 116 | case RenderingServer::SplashStretchMode::SPLASH_STRETCH_MODE_KEEP_HEIGHT: { |
| 117 | value = "scaleAspectFit"; |
| 118 | } break; |
| 119 | case RenderingServer::SplashStretchMode::SPLASH_STRETCH_MODE_COVER: { |
| 120 | value = "scaleAspectFill"; |
| 121 | } break; |
| 122 | case RenderingServer::SplashStretchMode::SPLASH_STRETCH_MODE_IGNORE: { |
| 123 | value = "scaleToFill"; |
| 124 | } break; |
| 125 | } |
| 126 | } |
| 127 | } break; |
| 128 | default: { |
| 129 | value = storyboard_image_scale_mode[image_scale_mode - 1]; |
| 130 | } |
| 131 | } |
| 132 | settings["ios/launch_screen_image_mode"] = value; |
| 133 | return settings; |
| 134 | } |
| 135 | |
| 136 | Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExportPreset> &p_preset, const String &p_dest_dir) { |
| 137 | const String custom_launch_image_2x = p_preset->get("storyboard/custom_image@2x"); |
| 138 | const String custom_launch_image_3x = p_preset->get("storyboard/custom_image@3x"); |
| 139 | |
| 140 | if (custom_launch_image_2x.length() > 0 && custom_launch_image_3x.length() > 0) { |
| 141 | String image_path = p_dest_dir.path_join("[email protected]"); |
| 142 | Error err = OK; |
| 143 | Ref<Image> image = _load_icon_or_splash_image(custom_launch_image_2x, &err); |
| 144 | |
| 145 | if (err != OK || image.is_null() || image->is_empty()) { |
| 146 | return err; |
| 147 | } |
| 148 | |
| 149 | if (image->save_png(image_path) != OK) { |
| 150 | return ERR_FILE_CANT_WRITE; |
| 151 | } |
| 152 | |
| 153 | image_path = p_dest_dir.path_join("[email protected]"); |
| 154 | image = _load_icon_or_splash_image(custom_launch_image_3x, &err); |
| 155 | |
| 156 | if (err != OK || image.is_null() || image->is_empty()) { |
| 157 | return err; |
| 158 | } |
| 159 | |
| 160 | if (image->save_png(image_path) != OK) { |
| 161 | return ERR_FILE_CANT_WRITE; |
| 162 | } |
| 163 | } else { |
| 164 | Error err = OK; |
| 165 | Ref<Image> splash; |
| 166 | |
| 167 | const String splash_path = get_project_setting(p_preset, "application/boot_splash/image"); |
| 168 | |
| 169 | if (!splash_path.is_empty()) { |
| 170 | splash = _load_icon_or_splash_image(splash_path, &err); |
| 171 | } |
| 172 | |
| 173 | if (err != OK || splash.is_null() || splash->is_empty()) { |
| 174 | splash.instantiate(boot_splash_png); |
| 175 | } |
| 176 | |
| 177 | // Using same image for both @2x and @3x |
| 178 | // because Godot's own boot logo uses single image for all resolutions. |
| 179 | // Also not using @1x image, because devices using this image variant |
| 180 | // are not supported by iOS 9, which is minimal target. |
| 181 | const String splash_png_path_2x = p_dest_dir.path_join("[email protected]"); |
| 182 | const String splash_png_path_3x = p_dest_dir.path_join("[email protected]"); |
| 183 | |
| 184 | if (splash->save_png(splash_png_path_2x) != OK) { |
| 185 | return ERR_FILE_CANT_WRITE; |
| 186 | } |
| 187 | |
| 188 | if (splash->save_png(splash_png_path_3x) != OK) { |
| 189 | return ERR_FILE_CANT_WRITE; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | return OK; |
| 194 | } |
| 195 | |
| 196 | Vector<EditorExportPlatformAppleEmbedded::IconInfo> EditorExportPlatformIOS::get_icon_infos() const { |
| 197 | Vector<EditorExportPlatformAppleEmbedded::IconInfo> icon_infos; |
| 198 | return { |
| 199 | // Settings on iPhone, iPad Pro, iPad, iPad mini |
| 200 | { PNAME("icons/settings_58x58"), "universal", "Icon-58", "58", "2x", "29x29", false }, |
| 201 | { PNAME("icons/settings_87x87"), "universal", "Icon-87", "87", "3x", "29x29", false }, |
| 202 | |
| 203 | // Notifications on iPhone, iPad Pro, iPad, iPad mini |
| 204 | { PNAME("icons/notification_40x40"), "universal", "Icon-40", "40", "2x", "20x20", false }, |
| 205 | { PNAME("icons/notification_60x60"), "universal", "Icon-60", "60", "3x", "20x20", false }, |
| 206 | { PNAME("icons/notification_76x76"), "universal", "Icon-76", "76", "2x", "38x38", false }, |
| 207 | { PNAME("icons/notification_114x114"), "universal", "Icon-114", "114", "3x", "38x38", false }, |
| 208 | |
| 209 | // Spotlight on iPhone, iPad Pro, iPad, iPad mini |
| 210 | { PNAME("icons/spotlight_80x80"), "universal", "Icon-80", "80", "2x", "40x40", false }, |
| 211 | { PNAME("icons/spotlight_120x120"), "universal", "Icon-120", "120", "3x", "40x40", false }, |
| 212 | |
| 213 | // Home Screen on iPhone |
| 214 | { PNAME("icons/iphone_120x120"), "universal", "Icon-120-1", "120", "2x", "60x60", false }, |
| 215 | { PNAME("icons/iphone_180x180"), "universal", "Icon-180", "180", "3x", "60x60", false }, |
| 216 | |
| 217 | // Home Screen on iPad Pro |
| 218 | { PNAME("icons/ipad_167x167"), "universal", "Icon-167", "167", "2x", "83.5x83.5", false }, |
| 219 | |
| 220 | // Home Screen on iPad, iPad mini |
| 221 | { PNAME("icons/ipad_152x152"), "universal", "Icon-152", "152", "2x", "76x76", false }, |
| 222 | |
| 223 | { PNAME("icons/ios_128x128"), "universal", "Icon-128", "128", "2x", "64x64", false }, |
| 224 | { PNAME("icons/ios_192x192"), "universal", "Icon-192", "192", "3x", "64x64", false }, |
| 225 | |
| 226 | { PNAME("icons/ios_136x136"), "universal", "Icon-136", "136", "2x", "68x68", false }, |
| 227 | |
| 228 | // App Store |
| 229 | { PNAME("icons/app_store_1024x1024"), "universal", "Icon-1024", "1024", "1x", "1024x1024", true }, |
| 230 | }; |
| 231 | } |
| 232 | |
| 233 | Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_preset, const String &p_iconset_dir) { |
| 234 | String json_description = "{\"images\":["; |
| 235 | String sizes; |
| 236 | |
| 237 | Ref<DirAccess> da = DirAccess::open(p_iconset_dir); |
| 238 | if (da.is_null()) { |
| 239 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export Icons"), vformat(TTR("Could not open a directory at path \"%s\"."), p_iconset_dir)); |
| 240 | return ERR_CANT_OPEN; |
| 241 | } |
| 242 | |
| 243 | Color boot_bg_color = get_project_setting(p_preset, "application/boot_splash/bg_color"); |
| 244 | |
| 245 | enum IconColorMode { |
| 246 | ICON_NORMAL, |
| 247 | ICON_DARK, |
| 248 | ICON_TINTED, |
| 249 | ICON_MAX, |
| 250 | }; |
| 251 | |
| 252 | Vector<IconInfo> icon_infos = get_icon_infos(); |
| 253 | bool first_icon = true; |
| 254 | for (int i = 0; i < icon_infos.size(); ++i) { |
| 255 | for (int color_mode = ICON_NORMAL; color_mode < ICON_MAX; color_mode++) { |
| 256 | IconInfo info = icon_infos[i]; |
| 257 | int side_size = String(info.actual_size_side).to_int(); |
| 258 | String key = info.preset_key; |
| 259 | String exp_name = info.export_name; |
| 260 | if (color_mode == ICON_DARK) { |
| 261 | key += "_dark"; |
| 262 | exp_name += "_dark"; |
| 263 | } else if (color_mode == ICON_TINTED) { |
| 264 | key += "_tinted"; |
| 265 | exp_name += "_tinted"; |
| 266 | } |
| 267 | exp_name += ".png"; |
| 268 | String icon_path = p_preset->get(key); |
| 269 | bool resize_waning = true; |
| 270 | if (icon_path.is_empty()) { |
| 271 | // Load and resize base icon. |
| 272 | key = "icons/icon_1024x1024"; |
| 273 | if (color_mode == ICON_DARK) { |
| 274 | key += "_dark"; |
| 275 | } else if (color_mode == ICON_TINTED) { |
| 276 | key += "_tinted"; |
| 277 | } |
| 278 | icon_path = p_preset->get(key); |
| 279 | resize_waning = false; |
| 280 | } |
| 281 | if (icon_path.is_empty()) { |
| 282 | if (color_mode != ICON_NORMAL) { |
| 283 | continue; |
| 284 | } |
| 285 | // Resize main app icon. |
| 286 | icon_path = get_project_setting(p_preset, "application/config/icon"); |
| 287 | Error err = OK; |
| 288 | Ref<Image> img = _load_icon_or_splash_image(icon_path, &err); |
| 289 | if (err != OK || img.is_null() || img->is_empty()) { |
| 290 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export Icons"), vformat("Invalid icon (%s): '%s'.", info.preset_key, icon_path)); |
| 291 | return ERR_UNCONFIGURED; |
| 292 | } else if (info.force_opaque && img->detect_alpha() != Image::ALPHA_NONE) { |
| 293 | img->resize(side_size, side_size, (Image::Interpolation)(p_preset->get("application/icon_interpolation").operator int())); |
| 294 | Ref<Image> new_img = Image::create_empty(side_size, side_size, false, Image::FORMAT_RGBA8); |
| 295 | new_img->fill(boot_bg_color); |
| 296 | _blend_and_rotate(new_img, img, false); |
| 297 | err = new_img->save_png(p_iconset_dir + exp_name); |
| 298 | } else { |
| 299 | img->resize(side_size, side_size, (Image::Interpolation)(p_preset->get("application/icon_interpolation").operator int())); |
| 300 | err = img->save_png(p_iconset_dir + exp_name); |
| 301 | } |
| 302 | if (err) { |
| 303 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export Icons"), vformat("Failed to export icon (%s): '%s'.", info.preset_key, icon_path)); |
| 304 | return err; |
| 305 | } |
| 306 | } else { |
| 307 | // Load custom icon and resize if required. |
| 308 | Error err = OK; |
| 309 | Ref<Image> img = _load_icon_or_splash_image(icon_path, &err); |
| 310 | if (err != OK || img.is_null() || img->is_empty()) { |
| 311 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export Icons"), vformat("Invalid icon (%s): '%s'.", info.preset_key, icon_path)); |
| 312 | return ERR_UNCONFIGURED; |
| 313 | } else if (info.force_opaque && img->detect_alpha() != Image::ALPHA_NONE) { |
| 314 | if (resize_waning) { |
| 315 | add_message(EXPORT_MESSAGE_WARNING, TTR("Export Icons"), vformat("Icon (%s) must be opaque.", info.preset_key)); |
| 316 | } |
| 317 | img->resize(side_size, side_size, (Image::Interpolation)(p_preset->get("application/icon_interpolation").operator int())); |
| 318 | Ref<Image> new_img = Image::create_empty(side_size, side_size, false, Image::FORMAT_RGBA8); |
| 319 | new_img->fill(boot_bg_color); |
| 320 | _blend_and_rotate(new_img, img, false); |
| 321 | err = new_img->save_png(p_iconset_dir + exp_name); |
| 322 | } else if (img->get_width() != side_size || img->get_height() != side_size) { |
| 323 | if (resize_waning) { |
| 324 | add_message(EXPORT_MESSAGE_WARNING, TTR("Export Icons"), vformat("Icon (%s): '%s' has incorrect size %s and was automatically resized to %s.", info.preset_key, icon_path, img->get_size(), Vector2i(side_size, side_size))); |
| 325 | } |
| 326 | img->resize(side_size, side_size, (Image::Interpolation)(p_preset->get("application/icon_interpolation").operator int())); |
| 327 | err = img->save_png(p_iconset_dir + exp_name); |
| 328 | } else if (!icon_path.ends_with(".png")) { |
| 329 | err = img->save_png(p_iconset_dir + exp_name); |
| 330 | } else { |
| 331 | err = da->copy(icon_path, p_iconset_dir + exp_name); |
| 332 | } |
| 333 | |
| 334 | if (err) { |
| 335 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export Icons"), vformat("Failed to export icon (%s): '%s'.", info.preset_key, icon_path)); |
| 336 | return err; |
| 337 | } |
| 338 | } |
| 339 | sizes += String(info.actual_size_side) + "\n"; |
| 340 | if (first_icon) { |
| 341 | first_icon = false; |
| 342 | } else { |
| 343 | json_description += ","; |
| 344 | } |
| 345 | json_description += String("{"); |
| 346 | if (color_mode != ICON_NORMAL) { |
| 347 | json_description += String("\"appearances\":[{"); |
| 348 | json_description += String("\"appearance\":\"luminosity\","); |
| 349 | if (color_mode == ICON_DARK) { |
| 350 | json_description += String("\"value\":\"dark\""); |
| 351 | } else if (color_mode == ICON_TINTED) { |
| 352 | json_description += String("\"value\":\"tinted\""); |
| 353 | } |
| 354 | json_description += String("}],"); |
| 355 | } |
| 356 | json_description += String("\"idiom\":") + "\"" + info.idiom + "\","; |
| 357 | json_description += String("\"platform\":\"" + get_platform_name() + "\","); |
| 358 | json_description += String("\"size\":") + "\"" + info.unscaled_size + "\","; |
| 359 | if (String(info.scale) != "1x") { |
| 360 | json_description += String("\"scale\":") + "\"" + info.scale + "\","; |
| 361 | } |
| 362 | json_description += String("\"filename\":") + "\"" + exp_name + "\""; |
| 363 | json_description += String("}"); |
| 364 | } |
| 365 | } |
| 366 | json_description += "],\"info\":{\"author\":\"xcode\",\"version\":1}}"; |
| 367 | |
| 368 | Ref<FileAccess> json_file = FileAccess::open(p_iconset_dir + "Contents.json", FileAccess::WRITE); |
| 369 | if (json_file.is_null()) { |
| 370 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export Icons"), vformat(TTR("Could not write to a file at path \"%s\"."), p_iconset_dir + "Contents.json")); |
| 371 | return ERR_CANT_CREATE; |
| 372 | } |
| 373 | |
| 374 | CharString json_utf8 = json_description.utf8(); |
| 375 | json_file->store_buffer((const uint8_t *)json_utf8.get_data(), json_utf8.length()); |
| 376 | |
| 377 | Ref<FileAccess> sizes_file = FileAccess::open(p_iconset_dir + "sizes", FileAccess::WRITE); |
| 378 | if (sizes_file.is_null()) { |
| 379 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export Icons"), vformat(TTR("Could not write to a file at path \"%s\"."), p_iconset_dir + "sizes")); |
| 380 | return ERR_CANT_CREATE; |
| 381 | } |
| 382 | |
| 383 | CharString sizes_utf8 = sizes.utf8(); |
| 384 | sizes_file->store_buffer((const uint8_t *)sizes_utf8.get_data(), sizes_utf8.length()); |
| 385 | |
| 386 | return OK; |
| 387 | } |
| 388 | |
| 389 | String EditorExportPlatformIOS::_process_config_file_line(const Ref<EditorExportPreset> &p_preset, const String &p_line, const AppleEmbeddedConfigData &p_config, bool p_debug, const CodeSigningDetails &p_code_signing) { |
| 390 | // Do iOS specific processing first, and call super implementation if there are no matches |
| 391 | |
| 392 | String strnew; |
| 393 | |
| 394 | // Supported Destinations |
| 395 | if (p_line.contains("$targeted_device_family")) { |
| 396 | String xcode_value; |
| 397 | switch ((int)p_preset->get("application/targeted_device_family")) { |
| 398 | case 0: // iPhone |
| 399 | xcode_value = "1"; |
| 400 | break; |
| 401 | case 1: // iPad |
| 402 | xcode_value = "2"; |
| 403 | break; |
| 404 | case 2: // iPhone & iPad |
| 405 | xcode_value = "1,2"; |
| 406 | break; |
| 407 | } |
| 408 | strnew += p_line.replace("$targeted_device_family", xcode_value) + "\n"; |
| 409 | |
| 410 | // MoltenVK Framework |
| 411 | } else if (p_line.contains("$moltenvk_buildfile")) { |
| 412 | String value = "9039D3BE24C093AC0020482C /* MoltenVK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9039D3BD24C093AC0020482C /* MoltenVK.xcframework */; };"; |
| 413 | strnew += p_line.replace("$moltenvk_buildfile", value) + "\n"; |
| 414 | } else if (p_line.contains("$moltenvk_fileref")) { |
| 415 | String value = "9039D3BD24C093AC0020482C /* MoltenVK.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = MoltenVK; path = MoltenVK.xcframework; sourceTree = \"<group>\"; };"; |
| 416 | strnew += p_line.replace("$moltenvk_fileref", value) + "\n"; |
| 417 | } else if (p_line.contains("$moltenvk_buildphase")) { |
| 418 | String value = "9039D3BE24C093AC0020482C /* MoltenVK.xcframework in Frameworks */,"; |
| 419 | strnew += p_line.replace("$moltenvk_buildphase", value) + "\n"; |
| 420 | } else if (p_line.contains("$moltenvk_buildgrp")) { |
| 421 | String value = "9039D3BD24C093AC0020482C /* MoltenVK.xcframework */,"; |
| 422 | strnew += p_line.replace("$moltenvk_buildgrp", value) + "\n"; |
| 423 | |
| 424 | // Launch Storyboard |
| 425 | } else if (p_line.contains("$plist_launch_screen_name")) { |
| 426 | String value = "<key>UILaunchStoryboardName</key>\n<string>Launch Screen</string>"; |
| 427 | strnew += p_line.replace("$plist_launch_screen_name", value) + "\n"; |
| 428 | } else if (p_line.contains("$pbx_launch_screen_file_reference")) { |
| 429 | String value = "90DD2D9D24B36E8000717FE1 = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = \"Launch Screen.storyboard\"; sourceTree = \"<group>\"; };"; |
| 430 | strnew += p_line.replace("$pbx_launch_screen_file_reference", value) + "\n"; |
| 431 | } else if (p_line.contains("$pbx_launch_screen_copy_files")) { |
| 432 | String value = "90DD2D9D24B36E8000717FE1 /* Launch Screen.storyboard */,"; |
| 433 | strnew += p_line.replace("$pbx_launch_screen_copy_files", value) + "\n"; |
| 434 | } else if (p_line.contains("$pbx_launch_screen_build_phase")) { |
| 435 | String value = "90DD2D9E24B36E8000717FE1 /* Launch Screen.storyboard in Resources */,"; |
| 436 | strnew += p_line.replace("$pbx_launch_screen_build_phase", value) + "\n"; |
| 437 | } else if (p_line.contains("$pbx_launch_screen_build_reference")) { |
| 438 | String value = "90DD2D9E24B36E8000717FE1 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 90DD2D9D24B36E8000717FE1 /* Launch Screen.storyboard */; };"; |
| 439 | strnew += p_line.replace("$pbx_launch_screen_build_reference", value) + "\n"; |
| 440 | |
| 441 | // Launch Storyboard customization |
| 442 | } else if (p_line.contains("$launch_screen_image_mode")) { |
| 443 | int image_scale_mode = p_preset->get("storyboard/image_scale_mode"); |
| 444 | String value; |
| 445 | |
| 446 | switch (image_scale_mode) { |
| 447 | case 0: { |
| 448 | String logo_path = get_project_setting(p_preset, "application/boot_splash/image"); |
| 449 | bool is_on = get_project_setting(p_preset, "application/boot_splash/fullsize"); |
| 450 | // If custom logo is not specified, Godot does not scale default one, so we should do the same. |
| 451 | value = (is_on && logo_path.length() > 0) ? "scaleAspectFit" : "center"; |
| 452 | } break; |
| 453 | default: { |
| 454 | value = storyboard_image_scale_mode[image_scale_mode - 1]; |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | strnew += p_line.replace("$launch_screen_image_mode", value) + "\n"; |
| 459 | } else if (p_line.contains("$launch_screen_background_color")) { |
| 460 | bool use_custom = p_preset->get("storyboard/use_custom_bg_color"); |
| 461 | Color color = use_custom ? p_preset->get("storyboard/custom_bg_color") : get_project_setting(p_preset, "application/boot_splash/bg_color"); |
| 462 | const String value_format = "red=\"$red\" green=\"$green\" blue=\"$blue\" alpha=\"$alpha\""; |
| 463 | |
| 464 | Dictionary value_dictionary; |
| 465 | value_dictionary["red"] = color.r; |
| 466 | value_dictionary["green"] = color.g; |
| 467 | value_dictionary["blue"] = color.b; |
| 468 | value_dictionary["alpha"] = color.a; |
| 469 | String value = value_format.format(value_dictionary, "$_"); |
| 470 | |
| 471 | strnew += p_line.replace("$launch_screen_background_color", value) + "\n"; |
| 472 | |
| 473 | // OS Deployment Target |
| 474 | } else if (p_line.contains("$os_deployment_target")) { |
| 475 | String min_version = p_preset->get("application/min_" + get_platform_name() + "_version"); |
| 476 | String value = "IPHONEOS_DEPLOYMENT_TARGET = " + min_version + ";"; |
| 477 | strnew += p_line.replace("$os_deployment_target", value) + "\n"; |
| 478 | |
| 479 | // Valid Archs |
| 480 | } else if (p_line.contains("$valid_archs")) { |
| 481 | strnew += p_line.replace("$valid_archs", "arm64 x86_64") + "\n"; |
| 482 | |
| 483 | // Apple Embedded common |
| 484 | } else { |
| 485 | strnew += EditorExportPlatformAppleEmbedded::_process_config_file_line(p_preset, p_line, p_config, p_debug, p_code_signing); |
| 486 | } |
| 487 | |
| 488 | return strnew; |
| 489 | } |