From 1564083c305442729a3a3d9b3d0a0ab9cc2edfd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?= <7645683+bruvzg@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:05:06 +0200 Subject: [PATCH] [iOS] Add options to specify additional entitlements and capabilities in the export settings. --- .../godot_ios/godot_ios.entitlements | 2 +- .../doc_classes/EditorExportPlatformIOS.xml | 22 ++++++++++++--- platform/ios/export/export_plugin.cpp | 27 ++++++++++++++++--- .../doc_classes/EditorExportPlatformMacOS.xml | 10 +++---- 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/misc/dist/ios_xcode/godot_ios/godot_ios.entitlements b/misc/dist/ios_xcode/godot_ios/godot_ios.entitlements index c9b58a85cf93..6a9e1af546e2 100644 --- a/misc/dist/ios_xcode/godot_ios/godot_ios.entitlements +++ b/misc/dist/ios_xcode/godot_ios/godot_ios.entitlements @@ -2,6 +2,6 @@ -$entitlements_push_notifications +$entitlements_full diff --git a/platform/ios/doc_classes/EditorExportPlatformIOS.xml b/platform/ios/doc_classes/EditorExportPlatformIOS.xml index 1d4a944dc48e..e6ffe18cce8e 100644 --- a/platform/ios/doc_classes/EditorExportPlatformIOS.xml +++ b/platform/ios/doc_classes/EditorExportPlatformIOS.xml @@ -76,6 +76,9 @@ If [code]true[/code], networking features related to Wi-Fi access are enabled. See [url=https://developer.apple.com/support/required-device-capabilities/]Required Device Capabilities[/url]. + + Additional data added to the [code]UIRequiredDeviceCapabilities[/code] array of the [code]Info.plist[/code] file. + Requires the graphics performance and features of the A12 Bionic and later chips (devices supporting all Vulkan renderer features). Enabling this option limits supported devices to: iPhone XS, iPhone XR, iPad Mini (5th gen.), iPad Air (3rd gen.), iPad (8th gen) and newer. @@ -84,15 +87,28 @@ Requires the graphics performance and features of the A17 Pro and later chips. Enabling this option limits supported devices to: iPhone 15 Pro and newer. - - If [code]true[/code], push notifications are enabled. See [url=https://developer.apple.com/support/required-device-capabilities/]Required Device Capabilities[/url]. - Path to the custom export template. If left empty, default template is used. Path to the custom export template. If left empty, default template is used. + + Additional data added to the root [code]<dict>[/code] section of the [url=https://developer.apple.com/documentation/bundleresources/entitlements].entitlements[/url] file. The value should be an XML section with pairs of key-value elements, for example: + [codeblock lang=text] + <key>key_name</key> + <string>value</string> + [/codeblock] + + + Enable to allow access to Game Center features. [url=https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_game-center]com.apple.developer.game-center[/url]. + + + Enable if app may perform better with a higher memory limit. [url=https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_kernel_increased-memory-limit]com.apple.developer.kernel.increased-memory-limit[/url]. + + + Environment for Apple Push Notification service. See [url=https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment]aps-environment[/url]. + App Store application icon file. If left empty, it will fallback to [member ProjectSettings.application/config/icon]. See [url=https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons]App icons[/url]. diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index ac60278ea0c0..c26dcbb54969 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -321,10 +321,15 @@ void EditorExportPlatformIOS::get_export_options(List *r_options) plugins_changed.clear(); plugins = found_plugins; + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "entitlements/increased_memory_limit"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "entitlements/game_center"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "entitlements/push_notifications", PROPERTY_HINT_ENUM, "Disabled,Production,Development"), "Disabled")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "entitlements/additional", PROPERTY_HINT_MULTILINE_TEXT), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/access_wifi"), false)); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/push_notifications"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/performance_gaming_tier"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/performance_a12"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "capabilities/additional"), PackedStringArray())); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "user_data/accessible_from_files_app"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "user_data/accessible_from_itunes_sharing"), false)); @@ -481,9 +486,20 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ strnew += lines[i].replace("$docs_in_place", ((bool)p_preset->get("user_data/accessible_from_files_app")) ? "" : "") + "\n"; } else if (lines[i].contains("$docs_sharing")) { strnew += lines[i].replace("$docs_sharing", ((bool)p_preset->get("user_data/accessible_from_itunes_sharing")) ? "" : "") + "\n"; - } else if (lines[i].contains("$entitlements_push_notifications")) { - bool is_on = p_preset->get("capabilities/push_notifications"); - strnew += lines[i].replace("$entitlements_push_notifications", is_on ? "aps-environmentdevelopment" : "") + "\n"; + } else if (lines[i].contains("$entitlements_full")) { + String entitlements; + if ((String)p_preset->get("entitlements/push_notifications") != "Disabled") { + entitlements += "aps-environment\n" + p_preset->get("entitlements/push_notifications").operator String().to_lower() + "" + "\n"; + } + if ((bool)p_preset->get("entitlements/game_center")) { + entitlements += "com.apple.developer.game-center\n\n"; + } + if ((bool)p_preset->get("entitlements/increased_memory_limit")) { + entitlements += "com.apple.developer.kernel.increased-memory-limit\n\n"; + } + entitlements += p_preset->get("entitlements/additional").operator String() + "\n"; + + strnew += lines[i].replace("$entitlements_full", entitlements); } else if (lines[i].contains("$required_device_capabilities")) { String capabilities; @@ -504,6 +520,9 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ for (int idx = 0; idx < capabilities_list.size(); idx++) { capabilities += "" + capabilities_list[idx] + "\n"; } + for (const String &cap : p_preset->get("capabilities/additional").operator PackedStringArray()) { + capabilities += "" + cap + "\n"; + } strnew += lines[i].replace("$required_device_capabilities", capabilities); } else if (lines[i].contains("$interface_orientations")) { diff --git a/platform/macos/doc_classes/EditorExportPlatformMacOS.xml b/platform/macos/doc_classes/EditorExportPlatformMacOS.xml index 6097623801a1..43efb60aadb9 100644 --- a/platform/macos/doc_classes/EditorExportPlatformMacOS.xml +++ b/platform/macos/doc_classes/EditorExportPlatformMacOS.xml @@ -76,11 +76,11 @@ Array of the additional command line arguments passed to the code signing tool. - Additional data added to the root [code]<dict>[/code] section of the [url=https://developer.apple.com/documentation/bundleresources/entitlements].entitlements[/url] file. The value should be an XML section with pairs of key-value elements, e.g.: - [codeblock lang=text] - <key>key_name</key> - <string>value</string> - [/codeblock] + Additional data added to the root [code]<dict>[/code] section of the [url=https://developer.apple.com/documentation/bundleresources/entitlements].entitlements[/url] file. The value should be an XML section with pairs of key-value elements, for example: + [codeblock lang=text] + <key>key_name</key> + <string>value</string> + [/codeblock] Enable to allow access to contacts in the user's address book, if it's enabled you should also provide usage message in the [member privacy/address_book_usage_description] option. See [url=https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_personal-information_addressbook]com.apple.security.personal-information.addressbook[/url].