Skip to content

Commit 326b221

Browse files
committed
Merge pull request #108794 from bruvzg/macos_actool_export
[macOS] Add support for exporting macOS 26 Liquid Glass icons.
2 parents 4588542 + 838cb0e commit 326b221

File tree

11 files changed

+132
-5
lines changed

11 files changed

+132
-5
lines changed

core/os/os.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,16 @@ String OS::get_bundle_resource_dir() const {
309309
return ".";
310310
}
311311

312-
// Path to macOS .app bundle embedded icon
312+
// Path to macOS .app bundle embedded icon (.icns file).
313313
String OS::get_bundle_icon_path() const {
314314
return String();
315315
}
316316

317+
// Name of macOS .app bundle embedded icon (Liquid Glass asset name).
318+
String OS::get_bundle_icon_name() const {
319+
return String();
320+
}
321+
317322
// OS specific path for user://
318323
String OS::get_user_data_dir(const String &p_user_dir) const {
319324
return ".";

core/os/os.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ class OS {
294294
virtual String get_temp_path() const;
295295
virtual String get_bundle_resource_dir() const;
296296
virtual String get_bundle_icon_path() const;
297+
virtual String get_bundle_icon_name() const;
297298

298299
virtual String get_user_data_dir(const String &p_user_dir) const;
299300
virtual String get_user_data_dir() const;

editor/inspector/editor_property_name_processor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
148148
capitalize_string_remaps["aa"] = "AA";
149149
capitalize_string_remaps["aabb"] = "AABB";
150150
capitalize_string_remaps["adb"] = "ADB";
151+
capitalize_string_remaps["actool"] = "actool";
151152
capitalize_string_remaps["ao"] = "AO";
152153
capitalize_string_remaps["api"] = "API";
153154
capitalize_string_remaps["apk"] = "APK";

main/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4567,8 +4567,13 @@ int Main::start() {
45674567
sml->add_current_scene(scene);
45684568

45694569
#ifdef MACOS_ENABLED
4570+
#ifndef TOOLS_ENABLED
4571+
if ((FileAccess::exists(OS::get_singleton()->get_bundle_resource_dir().path_join("Assets.car")) && !OS::get_singleton()->get_bundle_icon_name().is_empty()) || (!OS::get_singleton()->get_bundle_icon_path().is_empty())) {
4572+
has_icon = true; // Bundle has embedded icon, do not override with project icon.
4573+
}
4574+
#endif
45704575
String mac_icon_path = GLOBAL_GET("application/config/macos_native_icon");
4571-
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_ICON) && !mac_icon_path.is_empty()) {
4576+
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_ICON) && !mac_icon_path.is_empty() && !has_icon) {
45724577
DisplayServer::get_singleton()->set_native_icon(mac_icon_path);
45734578
has_icon = true;
45744579
}

misc/dist/macos_template.app/Contents/Info.plist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<string>$name</string>
1313
<key>CFBundleIconFile</key>
1414
<string>icon.icns</string>
15+
$liquid_glass_icon
1516
<key>CFBundleIdentifier</key>
1617
<string>$bundle_identifier</string>
1718
<key>CFBundleInfoDictionaryVersion</key>

platform/macos/doc_classes/EditorExportPlatformMacOS.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
<member name="application/icon_interpolation" type="int" setter="" getter="">
3939
Interpolation method used to resize application icon.
4040
</member>
41+
<member name="application/liquid_glass_icon" type="String" setter="" getter="">
42+
macOS 26 Liquid Glass icon source file. Use [url=https://developer.apple.com/icon-composer/]Icon Composer[/url] to create Liquid Glass icons.
43+
[b]Note:[/b] Supported when exporting from macOS only, Xcode 26+ required.
44+
[b]Note:[/b] Liquid Glass icons are supported on macOS 26 only, use [member application/icon] to set the icon for older macOS versions.
45+
</member>
4146
<member name="application/min_macos_version_arm64" type="String" setter="" getter="">
4247
Minimum version of macOS required for this application to run on Apple Silicon Macs, in the [code]major.minor.patch[/code] or [code]major.minor[/code] format, can only contain numeric characters ([code]0-9[/code]) and periods ([code].[/code]).
4348
</member>

platform/macos/export/export.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ void register_macos_exporter() {
4545
#else
4646
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/macos/rcodesign", PROPERTY_HINT_GLOBAL_FILE));
4747
#endif
48+
EDITOR_DEF_BASIC("export/macos/actool", "");
49+
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/macos/actool", PROPERTY_HINT_GLOBAL_FILE));
4850
#endif
4951

5052
Ref<EditorExportPlatformMacOS> platform;

platform/macos/export/export_plugin.cpp

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ bool EditorExportPlatformMacOS::get_export_option_visibility(const EditorExportP
306306
return false;
307307
}
308308

309+
#ifndef MACOS_ENABLED
310+
if (p_option == "application/liquid_glass_icon") {
311+
return false;
312+
}
313+
#endif
314+
309315
String custom_prof = p_preset->get("codesign/entitlements/custom_file");
310316
if (!custom_prof.is_empty() && p_option != "codesign/entitlements/custom_file" && p_option.begins_with("codesign/entitlements/")) {
311317
return false;
@@ -467,6 +473,7 @@ void EditorExportPlatformMacOS::get_export_options(List<ExportOption> *r_options
467473
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
468474

469475
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_wrapper", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1));
476+
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/liquid_glass_icon", PROPERTY_HINT_FILE, "*.icon"), ""));
470477
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.icns,*.png,*.webp,*.svg"), ""));
471478
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/icon_interpolation", PROPERTY_HINT_ENUM, "Nearest neighbor,Bilinear,Cubic,Trilinear,Lanczos"), 4));
472479
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/bundle_identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), "", false, true));
@@ -828,7 +835,7 @@ void EditorExportPlatformMacOS::_fix_privacy_manifest(const Ref<EditorExportPres
828835
}
829836
}
830837

831-
void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary) {
838+
void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary, bool p_lg_icon_exported, const String &p_lg_icon) {
832839
String str = String::utf8((const char *)plist.ptr(), plist.size());
833840
String strnew;
834841
Vector<String> lines = str.split("\n");
@@ -872,6 +879,12 @@ void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_pres
872879
strnew += lines[i].replace("$xcodever", p_preset->get("xcode/xcode_version")) + "\n";
873880
} else if (lines[i].contains("$xcodebuild")) {
874881
strnew += lines[i].replace("$xcodebuild", p_preset->get("xcode/xcode_build")) + "\n";
882+
} else if (lines[i].contains("$liquid_glass_icon")) {
883+
if (p_lg_icon_exported) {
884+
strnew += lines[i].replace("$liquid_glass_icon", "\t<key>CFBundleIconName</key>\n\t<string>" + p_lg_icon + "</string>\n");
885+
} else {
886+
strnew += lines[i].replace("$liquid_glass_icon", "");
887+
}
875888
} else if (lines[i].contains("$usage_descriptions")) {
876889
String descriptions;
877890
if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) {
@@ -933,6 +946,76 @@ void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_pres
933946
}
934947
}
935948

949+
Error EditorExportPlatformMacOS::_export_liquid_glass_icon(const Ref<EditorExportPreset> &p_preset, const String &p_app_path, const String &p_icon_path) {
950+
String actool = EDITOR_GET("export/macos/actool").operator String();
951+
if (actool.is_empty()) {
952+
actool = "actool";
953+
}
954+
955+
List<String> args;
956+
args.push_back("--version");
957+
String str;
958+
String err_str;
959+
int exitcode = 0;
960+
961+
Error err = OS::get_singleton()->execute(actool, args, &str, &exitcode, true);
962+
if (err != OK) {
963+
add_message(EXPORT_MESSAGE_WARNING, TTR("Liquid Glass Icons"), TTR("Could not start 'actool' executable."));
964+
return err;
965+
}
966+
PList info_plist;
967+
if (!info_plist.load_string(str, err_str)) {
968+
print_verbose(str);
969+
add_message(EXPORT_MESSAGE_WARNING, TTR("Liquid Glass Icons"), TTR("Could not read 'actool' version."));
970+
return err;
971+
}
972+
if (info_plist.get_root()->data_type == PList::PLNodeType::PL_NODE_TYPE_DICT && info_plist.get_root()->data_dict.has("com.apple.actool.version")) {
973+
Ref<PListNode> dict = info_plist.get_root()->data_dict["com.apple.actool.version"];
974+
if (dict->data_type == PList::PLNodeType::PL_NODE_TYPE_DICT && dict->data_dict.has("short-bundle-version")) {
975+
float version = String::utf8(dict->data_dict["short-bundle-version"]->data_string.get_data()).to_float();
976+
if (version < 26.0) {
977+
add_message(EXPORT_MESSAGE_WARNING, TTR("Liquid Glass Icons"), vformat(TTR("At least version 26.0 of 'actool' is required (version %f found)."), version));
978+
return ERR_UNAVAILABLE;
979+
}
980+
}
981+
}
982+
str.clear();
983+
984+
String plist = EditorPaths::get_singleton()->get_temp_dir().path_join("assetcatalog.plist");
985+
args.clear();
986+
args.push_back(ProjectSettings::get_singleton()->globalize_path(p_icon_path));
987+
args.push_back("--compile");
988+
args.push_back(p_app_path + "/Contents/Resources/");
989+
args.push_back("--output-format");
990+
args.push_back("human-readable-text");
991+
args.push_back("--lightweight-asset-runtime-mode");
992+
args.push_back("enabled");
993+
args.push_back("--app-icon");
994+
args.push_back(p_icon_path.get_file().get_basename());
995+
args.push_back("--include-all-app-icons");
996+
args.push_back("--enable-on-demand-resources");
997+
args.push_back("NO");
998+
args.push_back("--development-region");
999+
args.push_back("en");
1000+
args.push_back("--target-device");
1001+
args.push_back("mac");
1002+
args.push_back("--minimum-deployment-target");
1003+
args.push_back("26");
1004+
args.push_back("--platform");
1005+
args.push_back("macosx");
1006+
args.push_back("--output-partial-info-plist");
1007+
args.push_back(plist);
1008+
1009+
err = OS::get_singleton()->execute(actool, args, &str, &exitcode, true);
1010+
if (err != OK || str.contains("error:") || !FileAccess::exists(p_app_path + "/Contents/Resources/Assets.car") || !FileAccess::exists(plist)) {
1011+
print_verbose(str);
1012+
add_message(EXPORT_MESSAGE_WARNING, TTR("Liquid Glass Icons"), TTR("Could not export liquid glass icon:") + "\n" + str);
1013+
return err;
1014+
}
1015+
1016+
return OK;
1017+
}
1018+
9361019
/**
9371020
* If we're running the macOS version of the Godot editor we'll:
9381021
* - export our application bundle to a temporary folder
@@ -1861,7 +1944,16 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
18611944
}
18621945

18631946
if (file == "Contents/Info.plist") {
1864-
_fix_plist(p_preset, data, pkg_name);
1947+
bool lg_icon_expored = false;
1948+
String lg_icon = p_preset->get("application/liquid_glass_icon");
1949+
#ifdef MACOS_ENABLED
1950+
// Export liquid glass.
1951+
if (!lg_icon.is_empty()) {
1952+
lg_icon_expored = (_export_liquid_glass_icon(p_preset, tmp_app_path_name, lg_icon) == OK);
1953+
}
1954+
#endif
1955+
// Modify plist.
1956+
_fix_plist(p_preset, data, pkg_name, lg_icon_expored, lg_icon.get_file().get_basename());
18651957
}
18661958

18671959
if (file == "Contents/Resources/PrivacyInfo.xcprivacy") {

platform/macos/export/export_plugin.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ class EditorExportPlatformMacOS : public EditorExportPlatform {
8585
int menu_options = 0;
8686

8787
void _fix_privacy_manifest(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist);
88-
void _fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary);
88+
void _fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary, bool p_lg_icon_exported, const String &p_lg_icon);
8989
void _make_icon(const Ref<EditorExportPreset> &p_preset, const Ref<Image> &p_icon, Vector<uint8_t> &p_data);
9090

91+
Error _export_liquid_glass_icon(const Ref<EditorExportPreset> &p_preset, const String &p_app_path, const String &p_icon_path);
9192
Error _notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path);
9293
void _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn = true, bool p_set_id = false);
9394
void _code_sign_directory(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, const String &p_helper_ent_path, bool p_should_error_on_non_code = true);

platform/macos/os_macos.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class OS_MacOS : public OS_Unix {
103103
virtual String get_temp_path() const override;
104104
virtual String get_bundle_resource_dir() const override;
105105
virtual String get_bundle_icon_path() const override;
106+
virtual String get_bundle_icon_name() const override;
106107
virtual String get_godot_dir_name() const override;
107108

108109
virtual String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const override;

0 commit comments

Comments
 (0)