Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/platform/macos/export/export_plugin.cpp
10278 views
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 "core/io/image_loader.h"
37
#include "core/io/plist.h"
38
#include "core/string/translation.h"
39
#include "drivers/png/png_driver_common.h"
40
#include "editor/editor_node.h"
41
#include "editor/editor_string_names.h"
42
#include "editor/export/codesign.h"
43
#include "editor/export/lipo.h"
44
#include "editor/export/macho.h"
45
#include "editor/file_system/editor_paths.h"
46
#include "editor/import/resource_importer_texture_settings.h"
47
#include "editor/themes/editor_scale.h"
48
#include "scene/resources/image_texture.h"
49
50
#include "modules/svg/image_loader_svg.h"
51
52
void EditorExportPlatformMacOS::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const {
53
r_features->push_back(p_preset->get("binary_format/architecture"));
54
String architecture = p_preset->get("binary_format/architecture");
55
56
if (architecture == "universal" || architecture == "x86_64") {
57
r_features->push_back("s3tc");
58
r_features->push_back("bptc");
59
} else if (architecture == "arm64") {
60
r_features->push_back("etc2");
61
r_features->push_back("astc");
62
} else {
63
ERR_PRINT("Invalid architecture");
64
}
65
66
if (p_preset->get("shader_baker/enabled")) {
67
r_features->push_back("shader_baker");
68
}
69
70
if (architecture == "universal") {
71
r_features->push_back("x86_64");
72
r_features->push_back("arm64");
73
}
74
}
75
76
String EditorExportPlatformMacOS::get_export_option_warning(const EditorExportPreset *p_preset, const StringName &p_name) const {
77
if (p_preset) {
78
int dist_type = p_preset->get("export/distribution_type");
79
bool ad_hoc = false;
80
int codesign_tool = p_preset->get("codesign/codesign");
81
int notary_tool = p_preset->get("notarization/notarization");
82
switch (codesign_tool) {
83
case 1: { // built-in ad-hoc
84
ad_hoc = true;
85
} break;
86
case 2: { // "rcodesign"
87
ad_hoc = p_preset->get_or_env("codesign/certificate_file", ENV_MAC_CODESIGN_CERT_FILE).operator String().is_empty() || p_preset->get_or_env("codesign/certificate_password", ENV_MAC_CODESIGN_CERT_FILE).operator String().is_empty();
88
} break;
89
#ifdef MACOS_ENABLED
90
case 3: { // "codesign"
91
ad_hoc = (p_preset->get("codesign/identity") == "" || p_preset->get("codesign/identity") == "-");
92
} break;
93
#endif
94
default: {
95
};
96
}
97
98
if (p_name == "application/bundle_identifier") {
99
String identifier = p_preset->get("application/bundle_identifier");
100
String pn_err;
101
if (!is_package_name_valid(identifier, &pn_err)) {
102
return TTR("Invalid bundle identifier:") + " " + pn_err;
103
}
104
}
105
106
if (p_name == "shader_baker/enabled" && bool(p_preset->get("shader_baker/enabled"))) {
107
String export_renderer = GLOBAL_GET("rendering/renderer/rendering_method");
108
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {
109
return TTR("\"Shader Baker\" is not supported when using the Compatibility renderer.");
110
} else if (OS::get_singleton()->get_current_rendering_method() != export_renderer) {
111
return vformat(TTR("The editor is currently using a different renderer than what the target platform will use. \"Shader Baker\" won't be able to include core shaders. Switch to the \"%s\" renderer temporarily to fix this."), export_renderer);
112
}
113
}
114
115
if (p_name == "codesign/certificate_file" || p_name == "codesign/certificate_password" || p_name == "codesign/identity") {
116
if (dist_type == 2) {
117
if (ad_hoc) {
118
return TTR("App Store distribution with ad-hoc code signing is not supported.");
119
}
120
} else if (notary_tool > 0 && ad_hoc) {
121
return TTR("Notarization with an ad-hoc signature is not supported.");
122
}
123
}
124
125
if (p_name == "codesign/apple_team_id") {
126
String team_id = p_preset->get("codesign/apple_team_id");
127
if (team_id.is_empty()) {
128
if (dist_type == 2) {
129
return TTR("Apple Team ID is required for App Store distribution.");
130
} else if (notary_tool > 0) {
131
return TTR("Apple Team ID is required for notarization.");
132
}
133
}
134
}
135
136
if (p_name == "codesign/provisioning_profile" && dist_type == 2) {
137
String pprof = p_preset->get_or_env("codesign/provisioning_profile", ENV_MAC_CODESIGN_PROFILE);
138
if (pprof.is_empty()) {
139
return TTR("Provisioning profile is required for App Store distribution.");
140
}
141
}
142
143
if (p_name == "codesign/installer_identity" && dist_type == 2) {
144
String ident = p_preset->get("codesign/installer_identity");
145
if (ident.is_empty()) {
146
return TTR("Installer signing identity is required for App Store distribution.");
147
}
148
}
149
150
if (p_name == "codesign/entitlements/app_sandbox/enabled" && dist_type == 2) {
151
bool sandbox = p_preset->get("codesign/entitlements/app_sandbox/enabled");
152
if (!sandbox) {
153
return TTR("App sandbox is required for App Store distribution.");
154
}
155
}
156
157
if (p_name == "codesign/codesign") {
158
if (dist_type == 2) {
159
if (codesign_tool == 2 && ClassDB::class_exists("CSharpScript")) {
160
return TTR("'rcodesign' doesn't support signing applications with embedded dynamic libraries (GDExtension or .NET).");
161
}
162
if (codesign_tool == 0) {
163
return TTR("Code signing is required for App Store distribution.");
164
}
165
if (codesign_tool == 1) {
166
return TTR("App Store distribution with ad-hoc code signing is not supported.");
167
}
168
} else if (notary_tool > 0) {
169
if (codesign_tool == 0) {
170
return TTR("Code signing is required for notarization.");
171
}
172
if (codesign_tool == 1) {
173
return TTR("Notarization with an ad-hoc signature is not supported.");
174
}
175
}
176
}
177
178
if (notary_tool == 2 || notary_tool == 3) {
179
if (p_name == "notarization/apple_id_name" || p_name == "notarization/api_uuid") {
180
String apple_id = p_preset->get_or_env("notarization/apple_id_name", ENV_MAC_NOTARIZATION_APPLE_ID);
181
String api_uuid = p_preset->get_or_env("notarization/api_uuid", ENV_MAC_NOTARIZATION_UUID);
182
if (apple_id.is_empty() && api_uuid.is_empty()) {
183
return TTR("Neither Apple ID name nor App Store Connect issuer ID name not specified.");
184
}
185
if (!apple_id.is_empty() && !api_uuid.is_empty()) {
186
return TTR("Both Apple ID name and App Store Connect issuer ID name are specified, only one should be set at the same time.");
187
}
188
}
189
if (p_name == "notarization/apple_id_password") {
190
String apple_id = p_preset->get_or_env("notarization/apple_id_name", ENV_MAC_NOTARIZATION_APPLE_ID);
191
String apple_pass = p_preset->get_or_env("notarization/apple_id_password", ENV_MAC_NOTARIZATION_APPLE_PASS);
192
if (!apple_id.is_empty() && apple_pass.is_empty()) {
193
return TTR("Apple ID password not specified.");
194
}
195
}
196
if (p_name == "notarization/api_key_id") {
197
String api_uuid = p_preset->get_or_env("notarization/api_uuid", ENV_MAC_NOTARIZATION_UUID);
198
String api_key = p_preset->get_or_env("notarization/api_key_id", ENV_MAC_NOTARIZATION_KEY_ID);
199
if (!api_uuid.is_empty() && api_key.is_empty()) {
200
return TTR("App Store Connect API key ID not specified.");
201
}
202
}
203
} else if (notary_tool == 1) {
204
if (p_name == "notarization/api_uuid") {
205
String api_uuid = p_preset->get_or_env("notarization/api_uuid", ENV_MAC_NOTARIZATION_UUID);
206
if (api_uuid.is_empty()) {
207
return TTR("App Store Connect issuer ID name not specified.");
208
}
209
}
210
if (p_name == "notarization/api_key_id") {
211
String api_key = p_preset->get_or_env("notarization/api_key_id", ENV_MAC_NOTARIZATION_KEY_ID);
212
if (api_key.is_empty()) {
213
return TTR("App Store Connect API key ID not specified.");
214
}
215
}
216
}
217
218
if (codesign_tool > 0) {
219
if (p_name == "privacy/microphone_usage_description") {
220
String discr = p_preset->get("privacy/microphone_usage_description");
221
bool enabled = p_preset->get("codesign/entitlements/audio_input");
222
if (enabled && discr.is_empty()) {
223
return TTR("Microphone access is enabled, but usage description is not specified.");
224
}
225
}
226
if (p_name == "privacy/camera_usage_description") {
227
String discr = p_preset->get("privacy/camera_usage_description");
228
bool enabled = p_preset->get("codesign/entitlements/camera");
229
if (enabled && discr.is_empty()) {
230
return TTR("Camera access is enabled, but usage description is not specified.");
231
}
232
}
233
if (p_name == "privacy/location_usage_description") {
234
String discr = p_preset->get("privacy/location_usage_description");
235
bool enabled = p_preset->get("codesign/entitlements/location");
236
if (enabled && discr.is_empty()) {
237
return TTR("Location information access is enabled, but usage description is not specified.");
238
}
239
}
240
if (p_name == "privacy/address_book_usage_description") {
241
String discr = p_preset->get("privacy/address_book_usage_description");
242
bool enabled = p_preset->get("codesign/entitlements/address_book");
243
if (enabled && discr.is_empty()) {
244
return TTR("Address book access is enabled, but usage description is not specified.");
245
}
246
}
247
if (p_name == "privacy/calendar_usage_description") {
248
String discr = p_preset->get("privacy/calendar_usage_description");
249
bool enabled = p_preset->get("codesign/entitlements/calendars");
250
if (enabled && discr.is_empty()) {
251
return TTR("Calendar access is enabled, but usage description is not specified.");
252
}
253
}
254
if (p_name == "privacy/photos_library_usage_description") {
255
String discr = p_preset->get("privacy/photos_library_usage_description");
256
bool enabled = p_preset->get("codesign/entitlements/photos_library");
257
if (enabled && discr.is_empty()) {
258
return TTR("Photo library access is enabled, but usage description is not specified.");
259
}
260
}
261
}
262
}
263
return String();
264
}
265
266
bool EditorExportPlatformMacOS::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const {
267
// Hide irrelevant code signing options.
268
if (p_preset) {
269
int codesign_tool = p_preset->get("codesign/codesign");
270
switch (codesign_tool) {
271
case 1: { // built-in ad-hoc
272
if (p_option == "codesign/identity" || p_option == "codesign/certificate_file" || p_option == "codesign/certificate_password" || p_option == "codesign/custom_options" || p_option == "codesign/team_id") {
273
return false;
274
}
275
} break;
276
case 2: { // "rcodesign"
277
if (p_option == "codesign/identity") {
278
return false;
279
}
280
} break;
281
#ifdef MACOS_ENABLED
282
case 3: { // "codesign"
283
if (p_option == "codesign/certificate_file" || p_option == "codesign/certificate_password") {
284
return false;
285
}
286
} break;
287
#endif
288
default: { // disabled
289
if (p_option == "codesign/identity" || p_option == "codesign/certificate_file" || p_option == "codesign/certificate_password" || p_option == "codesign/custom_options" || p_option.begins_with("codesign/entitlements") || p_option == "codesign/team_id") {
290
return false;
291
}
292
} break;
293
}
294
295
// Distribution type.
296
int dist_type = p_preset->get("export/distribution_type");
297
if (dist_type != 2 && p_option == "codesign/installer_identity") {
298
return false;
299
}
300
301
if (dist_type == 2 && p_option.begins_with("notarization/")) {
302
return false;
303
}
304
305
if (dist_type != 2 && p_option == "codesign/provisioning_profile") {
306
return false;
307
}
308
309
String custom_prof = p_preset->get("codesign/entitlements/custom_file");
310
if (!custom_prof.is_empty() && p_option != "codesign/entitlements/custom_file" && p_option.begins_with("codesign/entitlements/")) {
311
return false;
312
}
313
314
// Hide sandbox entitlements.
315
bool sandbox = p_preset->get("codesign/entitlements/app_sandbox/enabled");
316
if (!sandbox && p_option != "codesign/entitlements/app_sandbox/enabled" && p_option.begins_with("codesign/entitlements/app_sandbox/")) {
317
return false;
318
}
319
320
// Hide SSH options.
321
bool ssh = p_preset->get("ssh_remote_deploy/enabled");
322
if (!ssh && p_option != "ssh_remote_deploy/enabled" && p_option.begins_with("ssh_remote_deploy/")) {
323
return false;
324
}
325
326
// Hide irrelevant notarization options.
327
int notary_tool = p_preset->get("notarization/notarization");
328
switch (notary_tool) {
329
case 1: { // "rcodesign"
330
if (p_option == "notarization/apple_id_name" || p_option == "notarization/apple_id_password") {
331
return false;
332
}
333
} break;
334
case 2: { // "notarytool"
335
// All options are visible.
336
} break;
337
default: { // disabled
338
if (p_option == "notarization/apple_id_name" || p_option == "notarization/apple_id_password" || p_option == "notarization/api_uuid" || p_option == "notarization/api_key" || p_option == "notarization/api_key_id") {
339
return false;
340
}
341
} break;
342
}
343
344
bool advanced_options_enabled = p_preset->are_advanced_options_enabled();
345
if (p_option.begins_with("privacy") ||
346
p_option == "codesign/entitlements/additional" ||
347
p_option == "custom_template/debug" ||
348
p_option == "custom_template/release" ||
349
p_option == "application/additional_plist_content" ||
350
p_option == "application/export_angle" ||
351
p_option == "application/icon_interpolation" ||
352
p_option == "application/signature" ||
353
p_option == "display/high_res" ||
354
p_option == "xcode/platform_build" ||
355
p_option == "xcode/sdk_build" ||
356
p_option == "xcode/sdk_name" ||
357
p_option == "xcode/sdk_version" ||
358
p_option == "xcode/xcode_build" ||
359
p_option == "xcode/xcode_version") {
360
return advanced_options_enabled;
361
}
362
}
363
364
// These entitlements are required to run managed code, and are always enabled in Mono builds.
365
if (ClassDB::class_exists("CSharpScript")) {
366
if (p_option == "codesign/entitlements/allow_jit_code_execution" || p_option == "codesign/entitlements/allow_unsigned_executable_memory" || p_option == "codesign/entitlements/allow_dyld_environment_variables") {
367
return false;
368
}
369
}
370
371
// Hide unsupported .NET embedding option.
372
if (p_option == "dotnet/embed_build_outputs") {
373
return false;
374
}
375
376
return true;
377
}
378
379
List<String> EditorExportPlatformMacOS::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
380
List<String> list;
381
382
if (p_preset.is_valid()) {
383
int dist_type = p_preset->get("export/distribution_type");
384
if (dist_type == 0) {
385
#ifdef MACOS_ENABLED
386
list.push_back("dmg");
387
#endif
388
list.push_back("zip");
389
list.push_back("app");
390
} else if (dist_type == 1) {
391
#ifdef MACOS_ENABLED
392
list.push_back("dmg");
393
#endif
394
list.push_back("zip");
395
list.push_back("app");
396
} else if (dist_type == 2) {
397
#ifdef MACOS_ENABLED
398
list.push_back("pkg");
399
#endif
400
}
401
}
402
403
return list;
404
}
405
406
struct DataCollectionInfo {
407
String prop_name;
408
String type_name;
409
};
410
411
static const DataCollectionInfo data_collect_type_info[] = {
412
{ "name", "NSPrivacyCollectedDataTypeName" },
413
{ "email_address", "NSPrivacyCollectedDataTypeEmailAddress" },
414
{ "phone_number", "NSPrivacyCollectedDataTypePhoneNumber" },
415
{ "physical_address", "NSPrivacyCollectedDataTypePhysicalAddress" },
416
{ "other_contact_info", "NSPrivacyCollectedDataTypeOtherUserContactInfo" },
417
{ "health", "NSPrivacyCollectedDataTypeHealth" },
418
{ "fitness", "NSPrivacyCollectedDataTypeFitness" },
419
{ "payment_info", "NSPrivacyCollectedDataTypePaymentInfo" },
420
{ "credit_info", "NSPrivacyCollectedDataTypeCreditInfo" },
421
{ "other_financial_info", "NSPrivacyCollectedDataTypeOtherFinancialInfo" },
422
{ "precise_location", "NSPrivacyCollectedDataTypePreciseLocation" },
423
{ "coarse_location", "NSPrivacyCollectedDataTypeCoarseLocation" },
424
{ "sensitive_info", "NSPrivacyCollectedDataTypeSensitiveInfo" },
425
{ "contacts", "NSPrivacyCollectedDataTypeContacts" },
426
{ "emails_or_text_messages", "NSPrivacyCollectedDataTypeEmailsOrTextMessages" },
427
{ "photos_or_videos", "NSPrivacyCollectedDataTypePhotosorVideos" },
428
{ "audio_data", "NSPrivacyCollectedDataTypeAudioData" },
429
{ "gameplay_content", "NSPrivacyCollectedDataTypeGameplayContent" },
430
{ "customer_support", "NSPrivacyCollectedDataTypeCustomerSupport" },
431
{ "other_user_content", "NSPrivacyCollectedDataTypeOtherUserContent" },
432
{ "browsing_history", "NSPrivacyCollectedDataTypeBrowsingHistory" },
433
{ "search_hhistory", "NSPrivacyCollectedDataTypeSearchHistory" },
434
{ "user_id", "NSPrivacyCollectedDataTypeUserID" },
435
{ "device_id", "NSPrivacyCollectedDataTypeDeviceID" },
436
{ "purchase_history", "NSPrivacyCollectedDataTypePurchaseHistory" },
437
{ "product_interaction", "NSPrivacyCollectedDataTypeProductInteraction" },
438
{ "advertising_data", "NSPrivacyCollectedDataTypeAdvertisingData" },
439
{ "other_usage_data", "NSPrivacyCollectedDataTypeOtherUsageData" },
440
{ "crash_data", "NSPrivacyCollectedDataTypeCrashData" },
441
{ "performance_data", "NSPrivacyCollectedDataTypePerformanceData" },
442
{ "other_diagnostic_data", "NSPrivacyCollectedDataTypeOtherDiagnosticData" },
443
{ "environment_scanning", "NSPrivacyCollectedDataTypeEnvironmentScanning" },
444
{ "hands", "NSPrivacyCollectedDataTypeHands" },
445
{ "head", "NSPrivacyCollectedDataTypeHead" },
446
{ "other_data_types", "NSPrivacyCollectedDataTypeOtherDataTypes" },
447
};
448
449
static const DataCollectionInfo data_collect_purpose_info[] = {
450
{ "Analytics", "NSPrivacyCollectedDataTypePurposeAnalytics" },
451
{ "App Functionality", "NSPrivacyCollectedDataTypePurposeAppFunctionality" },
452
{ "Developer Advertising", "NSPrivacyCollectedDataTypePurposeDeveloperAdvertising" },
453
{ "Third-party Advertising", "NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising" },
454
{ "Product Personalization", "NSPrivacyCollectedDataTypePurposeProductPersonalization" },
455
{ "Other", "NSPrivacyCollectedDataTypePurposeOther" },
456
};
457
458
void EditorExportPlatformMacOS::get_export_options(List<ExportOption> *r_options) const {
459
#ifdef MACOS_ENABLED
460
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "export/distribution_type", PROPERTY_HINT_ENUM, "Testing,Distribution,App Store"), 1, true));
461
#else
462
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "export/distribution_type", PROPERTY_HINT_ENUM, "Testing,Distribution"), 1, true));
463
#endif
464
465
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "binary_format/architecture", PROPERTY_HINT_ENUM, "universal,x86_64,arm64", PROPERTY_USAGE_STORAGE), "universal"));
466
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
467
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
468
469
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_wrapper", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1));
470
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.icns,*.png,*.webp,*.svg"), ""));
471
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/icon_interpolation", PROPERTY_HINT_ENUM, "Nearest neighbor,Bilinear,Cubic,Trilinear,Lanczos"), 4));
472
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/bundle_identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), "", false, true));
473
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), ""));
474
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/app_category", PROPERTY_HINT_ENUM, "Business,Developer-tools,Education,Entertainment,Finance,Games,Action-games,Adventure-games,Arcade-games,Board-games,Card-games,Casino-games,Dice-games,Educational-games,Family-games,Kids-games,Music-games,Puzzle-games,Racing-games,Role-playing-games,Simulation-games,Sports-games,Strategy-games,Trivia-games,Word-games,Graphics-design,Healthcare-fitness,Lifestyle,Medical,Music,News,Photography,Productivity,Reference,Social-networking,Sports,Travel,Utilities,Video,Weather"), "Games"));
475
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version", PROPERTY_HINT_PLACEHOLDER_TEXT, "Leave empty to use project version"), ""));
476
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version", PROPERTY_HINT_PLACEHOLDER_TEXT, "Leave empty to use project version"), ""));
477
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));
478
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "application/copyright_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
479
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/min_macos_version_x86_64"), "10.12"));
480
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/min_macos_version_arm64"), "11.00"));
481
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/export_angle", PROPERTY_HINT_ENUM, "Auto,Yes,No"), 0, true));
482
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "display/high_res"), true));
483
484
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "shader_baker/enabled"), false));
485
486
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/additional_plist_content", PROPERTY_HINT_MULTILINE_TEXT), ""));
487
488
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "xcode/platform_build"), "14C18"));
489
// TODO(sgc): Need to set appropriate version when using Metal
490
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "xcode/sdk_version"), "13.1"));
491
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "xcode/sdk_build"), "22C55"));
492
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "xcode/sdk_name"), "macosx13.1"));
493
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "xcode/xcode_version"), "1420"));
494
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "xcode/xcode_build"), "14C18"));
495
496
#ifdef MACOS_ENABLED
497
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/codesign", PROPERTY_HINT_ENUM, "Disabled,Built-in (ad-hoc only),rcodesign,Xcode codesign"), 3, true));
498
#else
499
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/codesign", PROPERTY_HINT_ENUM, "Disabled,Built-in (ad-hoc only),rcodesign"), 1, true, true));
500
#endif
501
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/installer_identity", PROPERTY_HINT_PLACEHOLDER_TEXT, "3rd Party Mac Developer Installer: (ID)"), "", false, true));
502
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/apple_team_id", PROPERTY_HINT_PLACEHOLDER_TEXT, "ID"), "", false, true));
503
// "codesign" only options:
504
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/identity", PROPERTY_HINT_PLACEHOLDER_TEXT, "Type: Name (ID)"), ""));
505
// "rcodesign" only options:
506
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/certificate_file", PROPERTY_HINT_GLOBAL_FILE, "*.pfx,*.p12", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), ""));
507
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/certificate_password", PROPERTY_HINT_PASSWORD, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), ""));
508
// "codesign" and "rcodesign" only options:
509
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/provisioning_profile", PROPERTY_HINT_GLOBAL_FILE, "*.provisionprofile", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), "", false, true));
510
511
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/entitlements/custom_file", PROPERTY_HINT_GLOBAL_FILE, "*.plist"), "", true));
512
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_jit_code_execution"), false));
513
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_unsigned_executable_memory"), false));
514
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_dyld_environment_variables"), false));
515
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/disable_library_validation"), false));
516
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/audio_input"), false));
517
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/camera"), false));
518
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/location"), false));
519
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/address_book"), false));
520
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/calendars"), false));
521
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/photos_library"), false));
522
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/apple_events"), false));
523
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/debugging"), false));
524
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/enabled"), false, true, true));
525
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/network_server"), false));
526
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/network_client"), false));
527
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/device_usb"), false));
528
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/device_bluetooth"), false));
529
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_downloads", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
530
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_pictures", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
531
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_music", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
532
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_movies", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
533
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_user_selected", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
534
r_options->push_back(ExportOption(PropertyInfo(Variant::ARRAY, "codesign/entitlements/app_sandbox/helper_executables", PROPERTY_HINT_ARRAY_TYPE, itos(Variant::STRING) + "/" + itos(PROPERTY_HINT_GLOBAL_FILE) + ":"), Array()));
535
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/entitlements/additional", PROPERTY_HINT_MULTILINE_TEXT), ""));
536
r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "codesign/custom_options"), PackedStringArray()));
537
538
#ifdef MACOS_ENABLED
539
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "notarization/notarization", PROPERTY_HINT_ENUM, "Disabled,rcodesign,Xcode notarytool"), 0, true));
540
#else
541
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "notarization/notarization", PROPERTY_HINT_ENUM, "Disabled,rcodesign"), 0, true));
542
#endif
543
// "notarytool" only options:
544
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_id_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Apple ID email", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), "", false, true));
545
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_id_password", PROPERTY_HINT_PASSWORD, "Enable two-factor authentication and provide app-specific password", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), "", false, true));
546
// "notarytool" and "rcodesign" only options:
547
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/api_uuid", PROPERTY_HINT_PLACEHOLDER_TEXT, "App Store Connect issuer ID UUID", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), "", false, true));
548
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/api_key", PROPERTY_HINT_GLOBAL_FILE, "*.p8", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), "", false, true));
549
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/api_key_id", PROPERTY_HINT_PLACEHOLDER_TEXT, "App Store Connect API key ID", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), "", false, true));
550
551
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/microphone_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the microphone"), "", false, true));
552
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/microphone_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
553
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/camera_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the camera"), "", false, true));
554
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/camera_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
555
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/location_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the location information"), "", false, true));
556
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/location_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
557
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/address_book_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the address book"), "", false, true));
558
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/address_book_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
559
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/calendar_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the calendar"), "", false, true));
560
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/calendar_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
561
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photos_library_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the photo library"), "", false, true));
562
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/photos_library_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
563
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/desktop_folder_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use Desktop folder"), "", false, true));
564
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/desktop_folder_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
565
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/documents_folder_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use Documents folder"), "", false, true));
566
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/documents_folder_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
567
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/downloads_folder_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use Downloads folder"), "", false, true));
568
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/downloads_folder_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
569
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/network_volumes_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use network volumes"), "", false, true));
570
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/network_volumes_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
571
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/removable_volumes_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use removable volumes"), "", false, true));
572
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/removable_volumes_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
573
574
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "privacy/tracking_enabled"), false));
575
r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "privacy/tracking_domains"), Vector<String>()));
576
577
{
578
String hint;
579
for (uint64_t i = 0; i < std::size(data_collect_purpose_info); ++i) {
580
if (i != 0) {
581
hint += ",";
582
}
583
hint += vformat("%s:%d", data_collect_purpose_info[i].prop_name, (1 << i));
584
}
585
for (uint64_t i = 0; i < std::size(data_collect_type_info); ++i) {
586
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/collected", data_collect_type_info[i].prop_name)), false));
587
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/linked_to_user", data_collect_type_info[i].prop_name)), false));
588
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, vformat("privacy/collected_data/%s/used_for_tracking", data_collect_type_info[i].prop_name)), false));
589
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, vformat("privacy/collected_data/%s/collection_purposes", data_collect_type_info[i].prop_name), PROPERTY_HINT_FLAGS, hint), 0));
590
}
591
}
592
593
String run_script = "#!/usr/bin/env bash\n"
594
"unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"\n"
595
"open \"{temp_dir}/{exe_name}.app\" --args {cmd_args}";
596
597
String cleanup_script = "#!/usr/bin/env bash\n"
598
"kill $(pgrep -x -f \"{temp_dir}/{exe_name}.app/Contents/MacOS/{exe_name} {cmd_args}\")\n"
599
"rm -rf \"{temp_dir}\"";
600
601
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "ssh_remote_deploy/enabled"), false, true));
602
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/host"), "user@host_ip"));
603
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/port"), "22"));
604
605
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/extra_args_ssh", PROPERTY_HINT_MULTILINE_TEXT), ""));
606
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/extra_args_scp", PROPERTY_HINT_MULTILINE_TEXT), ""));
607
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/run_script", PROPERTY_HINT_MULTILINE_TEXT), run_script));
608
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/cleanup_script", PROPERTY_HINT_MULTILINE_TEXT), cleanup_script));
609
}
610
611
void _rgba8_to_packbits_encode(int p_ch, int p_size, Vector<uint8_t> &p_source, Vector<uint8_t> &p_dest) {
612
int src_len = p_size * p_size;
613
614
Vector<uint8_t> result;
615
616
int i = 0;
617
const uint8_t *src = p_source.ptr();
618
while (i < src_len) {
619
Vector<uint8_t> seq;
620
621
uint8_t count = 0;
622
while (count <= 0x7f && i < src_len) {
623
if (i + 2 < src_len && src[i * 4 + p_ch] == src[(i + 1) * 4 + p_ch] && src[i] == src[(i + 2) * 4 + p_ch]) {
624
break;
625
}
626
seq.push_back(src[i * 4 + p_ch]);
627
i++;
628
count++;
629
}
630
if (!seq.is_empty()) {
631
result.push_back(count - 1);
632
result.append_array(seq);
633
}
634
if (i >= src_len) {
635
break;
636
}
637
638
uint8_t rep = src[i * 4 + p_ch];
639
count = 0;
640
while (count <= 0x7f && i < src_len && src[i * 4 + p_ch] == rep) {
641
i++;
642
count++;
643
}
644
if (count >= 3) {
645
result.push_back(0x80 + count - 3);
646
result.push_back(rep);
647
} else {
648
result.push_back(count - 1);
649
for (int j = 0; j < count; j++) {
650
result.push_back(rep);
651
}
652
}
653
}
654
655
int ofs = p_dest.size();
656
p_dest.resize(p_dest.size() + result.size());
657
memcpy(&p_dest.write[ofs], result.ptr(), result.size());
658
}
659
660
void EditorExportPlatformMacOS::_make_icon(const Ref<EditorExportPreset> &p_preset, const Ref<Image> &p_icon, Vector<uint8_t> &p_data) {
661
Vector<uint8_t> data;
662
663
data.resize(8);
664
data.write[0] = 'i';
665
data.write[1] = 'c';
666
data.write[2] = 'n';
667
data.write[3] = 's';
668
669
struct MacOSIconInfo {
670
const char *name;
671
const char *mask_name;
672
bool is_png;
673
int size;
674
};
675
676
static const MacOSIconInfo icon_infos[] = {
677
{ "ic10", "", true, 1024 }, //1024×1024 32-bit PNG and 512×512@2x 32-bit "retina" PNG
678
{ "ic09", "", true, 512 }, //512×512 32-bit PNG
679
{ "ic14", "", true, 512 }, //256×256@2x 32-bit "retina" PNG
680
{ "ic08", "", true, 256 }, //256×256 32-bit PNG
681
{ "ic13", "", true, 256 }, //128×128@2x 32-bit "retina" PNG
682
{ "ic07", "", true, 128 }, //128×128 32-bit PNG
683
{ "ic12", "", true, 64 }, //32×32@2× 32-bit "retina" PNG
684
{ "ic11", "", true, 32 }, //16×16@2× 32-bit "retina" PNG
685
{ "il32", "l8mk", false, 32 }, //32×32 24-bit RLE + 8-bit uncompressed mask
686
{ "is32", "s8mk", false, 16 } //16×16 24-bit RLE + 8-bit uncompressed mask
687
};
688
689
for (uint64_t i = 0; i < std::size(icon_infos); ++i) {
690
Ref<Image> copy = p_icon->duplicate();
691
copy->convert(Image::FORMAT_RGBA8);
692
copy->resize(icon_infos[i].size, icon_infos[i].size, (Image::Interpolation)(p_preset->get("application/icon_interpolation").operator int()));
693
694
if (icon_infos[i].is_png) {
695
// Encode PNG icon.
696
Vector<uint8_t> png_buffer;
697
Error err = PNGDriverCommon::image_to_png(copy, png_buffer);
698
if (err == OK) {
699
int ofs = data.size();
700
uint64_t len = png_buffer.size();
701
data.resize(data.size() + len + 8);
702
memcpy(&data.write[ofs + 8], png_buffer.ptr(), len);
703
len += 8;
704
len = BSWAP32(len);
705
memcpy(&data.write[ofs], icon_infos[i].name, 4);
706
encode_uint32(len, &data.write[ofs + 4]);
707
}
708
} else {
709
Vector<uint8_t> src_data = copy->get_data();
710
711
// Encode 24-bit RGB RLE icon.
712
{
713
int ofs = data.size();
714
data.resize(data.size() + 8);
715
716
_rgba8_to_packbits_encode(0, icon_infos[i].size, src_data, data); // Encode R.
717
_rgba8_to_packbits_encode(1, icon_infos[i].size, src_data, data); // Encode G.
718
_rgba8_to_packbits_encode(2, icon_infos[i].size, src_data, data); // Encode B.
719
720
// Note: workaround for macOS icon decoder bug corrupting last RLE encoded value.
721
data.push_back(0x00);
722
723
int len = data.size() - ofs;
724
len = BSWAP32(len);
725
memcpy(&data.write[ofs], icon_infos[i].name, 4);
726
encode_uint32(len, &data.write[ofs + 4]);
727
}
728
729
// Encode 8-bit mask uncompressed icon.
730
{
731
int ofs = data.size();
732
int len = copy->get_width() * copy->get_height();
733
data.resize(data.size() + len + 8);
734
735
for (int j = 0; j < len; j++) {
736
data.write[ofs + 8 + j] = src_data.ptr()[j * 4 + 3];
737
}
738
len += 8;
739
len = BSWAP32(len);
740
memcpy(&data.write[ofs], icon_infos[i].mask_name, 4);
741
encode_uint32(len, &data.write[ofs + 4]);
742
}
743
}
744
}
745
746
uint32_t total_len = data.size();
747
total_len = BSWAP32(total_len);
748
encode_uint32(total_len, &data.write[4]);
749
750
p_data = data;
751
}
752
753
void EditorExportPlatformMacOS::_fix_privacy_manifest(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist) {
754
String str = String::utf8((const char *)plist.ptr(), plist.size());
755
String strnew;
756
Vector<String> lines = str.split("\n");
757
for (int i = 0; i < lines.size(); i++) {
758
if (lines[i].find("$priv_collection") != -1) {
759
bool section_opened = false;
760
for (uint64_t j = 0; j < std::size(data_collect_type_info); ++j) {
761
bool data_collected = p_preset->get(vformat("privacy/collected_data/%s/collected", data_collect_type_info[j].prop_name));
762
bool linked = p_preset->get(vformat("privacy/collected_data/%s/linked_to_user", data_collect_type_info[j].prop_name));
763
bool tracking = p_preset->get(vformat("privacy/collected_data/%s/used_for_tracking", data_collect_type_info[j].prop_name));
764
int purposes = p_preset->get(vformat("privacy/collected_data/%s/collection_purposes", data_collect_type_info[j].prop_name));
765
if (data_collected) {
766
if (!section_opened) {
767
section_opened = true;
768
strnew += "\t<key>NSPrivacyCollectedDataTypes</key>\n";
769
strnew += "\t<array>\n";
770
}
771
strnew += "\t\t<dict>\n";
772
strnew += "\t\t\t<key>NSPrivacyCollectedDataType</key>\n";
773
strnew += vformat("\t\t\t<string>%s</string>\n", data_collect_type_info[j].type_name);
774
strnew += "\t\t\t\t<key>NSPrivacyCollectedDataTypeLinked</key>\n";
775
if (linked) {
776
strnew += "\t\t\t\t<true/>\n";
777
} else {
778
strnew += "\t\t\t\t<false/>\n";
779
}
780
strnew += "\t\t\t\t<key>NSPrivacyCollectedDataTypeTracking</key>\n";
781
if (tracking) {
782
strnew += "\t\t\t\t<true/>\n";
783
} else {
784
strnew += "\t\t\t\t<false/>\n";
785
}
786
if (purposes != 0) {
787
strnew += "\t\t\t\t<key>NSPrivacyCollectedDataTypePurposes</key>\n";
788
strnew += "\t\t\t\t<array>\n";
789
for (uint64_t k = 0; k < std::size(data_collect_purpose_info); ++k) {
790
if (purposes & (1 << k)) {
791
strnew += vformat("\t\t\t\t\t<string>%s</string>\n", data_collect_purpose_info[k].type_name);
792
}
793
}
794
strnew += "\t\t\t\t</array>\n";
795
}
796
strnew += "\t\t\t</dict>\n";
797
}
798
}
799
if (section_opened) {
800
strnew += "\t</array>\n";
801
}
802
} else if (lines[i].find("$priv_tracking") != -1) {
803
bool tracking = p_preset->get("privacy/tracking_enabled");
804
strnew += "\t<key>NSPrivacyTracking</key>\n";
805
if (tracking) {
806
strnew += "\t<true/>\n";
807
} else {
808
strnew += "\t<false/>\n";
809
}
810
Vector<String> tracking_domains = p_preset->get("privacy/tracking_domains");
811
if (!tracking_domains.is_empty()) {
812
strnew += "\t<key>NSPrivacyTrackingDomains</key>\n";
813
strnew += "\t<array>\n";
814
for (const String &E : tracking_domains) {
815
strnew += "\t\t<string>" + E + "</string>\n";
816
}
817
strnew += "\t</array>\n";
818
}
819
} else {
820
strnew += lines[i] + "\n";
821
}
822
}
823
824
CharString cs = strnew.utf8();
825
plist.resize(cs.size() - 1);
826
for (int i = 0; i < cs.size() - 1; i++) {
827
plist.write[i] = cs[i];
828
}
829
}
830
831
void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary) {
832
String str = String::utf8((const char *)plist.ptr(), plist.size());
833
String strnew;
834
Vector<String> lines = str.split("\n");
835
for (int i = 0; i < lines.size(); i++) {
836
if (lines[i].contains("$binary")) {
837
strnew += lines[i].replace("$binary", p_binary) + "\n";
838
} else if (lines[i].contains("$name")) {
839
strnew += lines[i].replace("$name", get_project_setting(p_preset, "application/config/name")) + "\n";
840
} else if (lines[i].contains("$bundle_identifier")) {
841
strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n";
842
} else if (lines[i].contains("$short_version")) {
843
strnew += lines[i].replace("$short_version", p_preset->get_version("application/short_version")) + "\n";
844
} else if (lines[i].contains("$version")) {
845
strnew += lines[i].replace("$version", p_preset->get_version("application/version")) + "\n";
846
} else if (lines[i].contains("$signature")) {
847
strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n";
848
} else if (lines[i].contains("$app_category")) {
849
String cat = p_preset->get("application/app_category");
850
strnew += lines[i].replace("$app_category", cat.to_lower()) + "\n";
851
} else if (lines[i].contains("$copyright")) {
852
strnew += lines[i].replace("$copyright", p_preset->get("application/copyright")) + "\n";
853
} else if (lines[i].contains("$min_version_arm64")) {
854
strnew += lines[i].replace("$min_version_arm64", p_preset->get("application/min_macos_version_arm64")) + "\n";
855
} else if (lines[i].contains("$min_version_x86_64")) {
856
strnew += lines[i].replace("$min_version_x86_64", p_preset->get("application/min_macos_version_x86_64")) + "\n";
857
} else if (lines[i].contains("$min_version")) {
858
strnew += lines[i].replace("$min_version", p_preset->get("application/min_macos_version_x86_64")) + "\n"; // Old template, use x86-64 version for both.
859
} else if (lines[i].contains("$highres")) {
860
strnew += lines[i].replace("$highres", p_preset->get("display/high_res") ? "\t<true/>" : "\t<false/>") + "\n";
861
} else if (lines[i].contains("$additional_plist_content")) {
862
strnew += lines[i].replace("$additional_plist_content", p_preset->get("application/additional_plist_content")) + "\n";
863
} else if (lines[i].contains("$platfbuild")) {
864
strnew += lines[i].replace("$platfbuild", p_preset->get("xcode/platform_build")) + "\n";
865
} else if (lines[i].contains("$sdkver")) {
866
strnew += lines[i].replace("$sdkver", p_preset->get("xcode/sdk_version")) + "\n";
867
} else if (lines[i].contains("$sdkname")) {
868
strnew += lines[i].replace("$sdkname", p_preset->get("xcode/sdk_name")) + "\n";
869
} else if (lines[i].contains("$sdkbuild")) {
870
strnew += lines[i].replace("$sdkbuild", p_preset->get("xcode/sdk_build")) + "\n";
871
} else if (lines[i].contains("$xcodever")) {
872
strnew += lines[i].replace("$xcodever", p_preset->get("xcode/xcode_version")) + "\n";
873
} else if (lines[i].contains("$xcodebuild")) {
874
strnew += lines[i].replace("$xcodebuild", p_preset->get("xcode/xcode_build")) + "\n";
875
} else if (lines[i].contains("$usage_descriptions")) {
876
String descriptions;
877
if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) {
878
descriptions += "\t<key>NSMicrophoneUsageDescription</key>\n";
879
descriptions += "\t<string>" + (String)p_preset->get("privacy/microphone_usage_description") + "</string>\n";
880
}
881
if (!((String)p_preset->get("privacy/camera_usage_description")).is_empty()) {
882
descriptions += "\t<key>NSCameraUsageDescription</key>\n";
883
descriptions += "\t<string>" + (String)p_preset->get("privacy/camera_usage_description") + "</string>\n";
884
}
885
if (!((String)p_preset->get("privacy/location_usage_description")).is_empty()) {
886
descriptions += "\t<key>NSLocationUsageDescription</key>\n";
887
descriptions += "\t<string>" + (String)p_preset->get("privacy/location_usage_description") + "</string>\n";
888
}
889
if (!((String)p_preset->get("privacy/address_book_usage_description")).is_empty()) {
890
descriptions += "\t<key>NSContactsUsageDescription</key>\n";
891
descriptions += "\t<string>" + (String)p_preset->get("privacy/address_book_usage_description") + "</string>\n";
892
}
893
if (!((String)p_preset->get("privacy/calendar_usage_description")).is_empty()) {
894
descriptions += "\t<key>NSCalendarsUsageDescription</key>\n";
895
descriptions += "\t<string>" + (String)p_preset->get("privacy/calendar_usage_description") + "</string>\n";
896
}
897
if (!((String)p_preset->get("privacy/photos_library_usage_description")).is_empty()) {
898
descriptions += "\t<key>NSPhotoLibraryUsageDescription</key>\n";
899
descriptions += "\t<string>" + (String)p_preset->get("privacy/photos_library_usage_description") + "</string>\n";
900
}
901
if (!((String)p_preset->get("privacy/desktop_folder_usage_description")).is_empty()) {
902
descriptions += "\t<key>NSDesktopFolderUsageDescription</key>\n";
903
descriptions += "\t<string>" + (String)p_preset->get("privacy/desktop_folder_usage_description") + "</string>\n";
904
}
905
if (!((String)p_preset->get("privacy/documents_folder_usage_description")).is_empty()) {
906
descriptions += "\t<key>NSDocumentsFolderUsageDescription</key>\n";
907
descriptions += "\t<string>" + (String)p_preset->get("privacy/documents_folder_usage_description") + "</string>\n";
908
}
909
if (!((String)p_preset->get("privacy/downloads_folder_usage_description")).is_empty()) {
910
descriptions += "\t<key>NSDownloadsFolderUsageDescription</key>\n";
911
descriptions += "\t<string>" + (String)p_preset->get("privacy/downloads_folder_usage_description") + "</string>\n";
912
}
913
if (!((String)p_preset->get("privacy/network_volumes_usage_description")).is_empty()) {
914
descriptions += "\t<key>NSNetworkVolumesUsageDescription</key>\n";
915
descriptions += "\t<string>" + (String)p_preset->get("privacy/network_volumes_usage_description") + "</string>\n";
916
}
917
if (!((String)p_preset->get("privacy/removable_volumes_usage_description")).is_empty()) {
918
descriptions += "\t<key>NSRemovableVolumesUsageDescription</key>\n";
919
descriptions += "\t<string>" + (String)p_preset->get("privacy/removable_volumes_usage_description") + "</string>\n";
920
}
921
if (!descriptions.is_empty()) {
922
strnew += lines[i].replace("$usage_descriptions", descriptions);
923
}
924
} else {
925
strnew += lines[i] + "\n";
926
}
927
}
928
929
CharString cs = strnew.utf8();
930
plist.resize(cs.size() - 1);
931
for (int i = 0; i < cs.size() - 1; i++) {
932
plist.write[i] = cs[i];
933
}
934
}
935
936
/**
937
* If we're running the macOS version of the Godot editor we'll:
938
* - export our application bundle to a temporary folder
939
* - attempt to code sign it
940
* - and then wrap it up in a DMG
941
*/
942
943
Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
944
int notary_tool = p_preset->get("notarization/notarization");
945
switch (notary_tool) {
946
case 1: { // "rcodesign"
947
print_verbose("using rcodesign notarization...");
948
949
String rcodesign = EDITOR_GET("export/macos/rcodesign").operator String();
950
if (rcodesign.is_empty()) {
951
add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("rcodesign path is not set. Configure rcodesign path in the Editor Settings (Export > macOS > rcodesign)."));
952
return Error::FAILED;
953
}
954
955
List<String> args;
956
957
args.push_back("notary-submit");
958
959
if (p_preset->get_or_env("notarization/api_uuid", ENV_MAC_NOTARIZATION_UUID) == "") {
960
add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("App Store Connect issuer ID name not specified."));
961
return Error::FAILED;
962
}
963
if (p_preset->get_or_env("notarization/api_key", ENV_MAC_NOTARIZATION_KEY) == "") {
964
add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("App Store Connect API key ID not specified."));
965
return Error::FAILED;
966
}
967
968
args.push_back("--api-issuer");
969
args.push_back(p_preset->get_or_env("notarization/api_uuid", ENV_MAC_NOTARIZATION_UUID));
970
971
args.push_back("--api-key");
972
args.push_back(p_preset->get_or_env("notarization/api_key_id", ENV_MAC_NOTARIZATION_KEY_ID));
973
974
if (!p_preset->get_or_env("notarization/api_key", ENV_MAC_NOTARIZATION_KEY).operator String().is_empty()) {
975
args.push_back("--api-key-path");
976
args.push_back(p_preset->get_or_env("notarization/api_key", ENV_MAC_NOTARIZATION_KEY));
977
}
978
979
args.push_back(p_path);
980
981
String str;
982
int exitcode = 0;
983
984
Error err = OS::get_singleton()->execute(rcodesign, args, &str, &exitcode, true);
985
if (err != OK) {
986
add_message(EXPORT_MESSAGE_WARNING, TTR("Notarization"), TTR("Could not start rcodesign executable."));
987
return err;
988
}
989
990
int rq_offset = str.find("created submission ID:");
991
if (exitcode != 0 || rq_offset == -1) {
992
print_line("rcodesign (" + p_path + "):\n" + str);
993
add_message(EXPORT_MESSAGE_WARNING, TTR("Notarization"), TTR("Notarization failed, see editor log for details."));
994
return Error::FAILED;
995
} else {
996
print_verbose("rcodesign (" + p_path + "):\n" + str);
997
int next_nl = str.find_char('\n', rq_offset);
998
String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 23) : str.substr(rq_offset + 23, next_nl - rq_offset - 23);
999
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid));
1000
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour."));
1001
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("You can check progress manually by opening a Terminal and running the following command:"));
1002
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t\t\"rcodesign notary-log --api-issuer <api uuid> --api-key <api key> <request uuid>\"");
1003
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("Run the following command to staple the notarization ticket to the exported application (optional):"));
1004
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t\t\"rcodesign staple <app path>\"");
1005
}
1006
} break;
1007
#ifdef MACOS_ENABLED
1008
case 2: { // "notarytool"
1009
print_verbose("using notarytool notarization...");
1010
1011
if (!FileAccess::exists("/usr/bin/xcrun") && !FileAccess::exists("/bin/xcrun")) {
1012
add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("Xcode command line tools are not installed."));
1013
return Error::FAILED;
1014
}
1015
1016
List<String> args;
1017
1018
args.push_back("notarytool");
1019
args.push_back("submit");
1020
1021
args.push_back(p_path);
1022
1023
if (p_preset->get_or_env("notarization/apple_id_name", ENV_MAC_NOTARIZATION_APPLE_ID) == "" && p_preset->get_or_env("notarization/api_uuid", ENV_MAC_NOTARIZATION_UUID) == "") {
1024
add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("Neither Apple ID name nor App Store Connect issuer ID name not specified."));
1025
return Error::FAILED;
1026
}
1027
if (p_preset->get_or_env("notarization/apple_id_name", ENV_MAC_NOTARIZATION_APPLE_ID) != "" && p_preset->get_or_env("notarization/api_uuid", ENV_MAC_NOTARIZATION_UUID) != "") {
1028
add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("Both Apple ID name and App Store Connect issuer ID name are specified, only one should be set at the same time."));
1029
return Error::FAILED;
1030
}
1031
1032
if (p_preset->get_or_env("notarization/apple_id_name", ENV_MAC_NOTARIZATION_APPLE_ID) != "") {
1033
if (p_preset->get_or_env("notarization/apple_id_password", ENV_MAC_NOTARIZATION_APPLE_PASS) == "") {
1034
add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("Apple ID password not specified."));
1035
return Error::FAILED;
1036
}
1037
args.push_back("--apple-id");
1038
args.push_back(p_preset->get_or_env("notarization/apple_id_name", ENV_MAC_NOTARIZATION_APPLE_ID));
1039
1040
args.push_back("--password");
1041
args.push_back(p_preset->get_or_env("notarization/apple_id_password", ENV_MAC_NOTARIZATION_APPLE_PASS));
1042
} else {
1043
if (p_preset->get_or_env("notarization/api_key_id", ENV_MAC_NOTARIZATION_KEY_ID) == "") {
1044
add_message(EXPORT_MESSAGE_ERROR, TTR("Notarization"), TTR("App Store Connect API key ID not specified."));
1045
return Error::FAILED;
1046
}
1047
args.push_back("--issuer");
1048
args.push_back(p_preset->get_or_env("notarization/api_uuid", ENV_MAC_NOTARIZATION_UUID));
1049
1050
if (!p_preset->get_or_env("notarization/api_key", ENV_MAC_NOTARIZATION_KEY).operator String().is_empty()) {
1051
args.push_back("--key");
1052
args.push_back(p_preset->get_or_env("notarization/api_key", ENV_MAC_NOTARIZATION_KEY));
1053
}
1054
1055
args.push_back("--key-id");
1056
args.push_back(p_preset->get_or_env("notarization/api_key_id", ENV_MAC_NOTARIZATION_KEY_ID));
1057
}
1058
1059
args.push_back("--no-progress");
1060
1061
if (p_preset->get("codesign/apple_team_id")) {
1062
args.push_back("--team-id");
1063
args.push_back(p_preset->get("codesign/apple_team_id"));
1064
}
1065
1066
String str;
1067
int exitcode = 0;
1068
Error err = OS::get_singleton()->execute("xcrun", args, &str, &exitcode, true);
1069
if (err != OK) {
1070
add_message(EXPORT_MESSAGE_WARNING, TTR("Notarization"), TTR("Could not start xcrun executable."));
1071
return err;
1072
}
1073
1074
int rq_offset = str.find("id:");
1075
if (exitcode != 0 || rq_offset == -1) {
1076
print_line("notarytool (" + p_path + "):\n" + str);
1077
add_message(EXPORT_MESSAGE_WARNING, TTR("Notarization"), TTR("Notarization failed, see editor log for details."));
1078
return Error::FAILED;
1079
} else {
1080
print_verbose("notarytool (" + p_path + "):\n" + str);
1081
int next_nl = str.find_char('\n', rq_offset);
1082
String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 4) : str.substr(rq_offset + 4, next_nl - rq_offset - 4);
1083
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid));
1084
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour."));
1085
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("You can check progress manually by opening a Terminal and running the following command:"));
1086
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t\t\"xcrun notarytool log <request uuid> --issuer <api uuid> --key-id <api key id> --key <api key path>\" or");
1087
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t\t\"xcrun notarytool log <request uuid> --apple-id <your email> --password <app-specific pwd>>\"");
1088
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("Run the following command to staple the notarization ticket to the exported application (optional):"));
1089
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t\t\"xcrun stapler staple <app path>\"");
1090
}
1091
} break;
1092
#endif
1093
default: {
1094
};
1095
}
1096
return OK;
1097
}
1098
1099
void EditorExportPlatformMacOS::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn, bool p_set_id) {
1100
int codesign_tool = p_preset->get("codesign/codesign");
1101
switch (codesign_tool) {
1102
case 1: { // built-in ad-hoc
1103
print_verbose("using built-in codesign...");
1104
String error_msg;
1105
Error err = CodeSign::codesign(false, true, p_path, p_ent_path, error_msg);
1106
if (err != OK) {
1107
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Built-in CodeSign failed with error \"%s\"."), error_msg));
1108
return;
1109
}
1110
} break;
1111
case 2: { // "rcodesign"
1112
print_verbose("using rcodesign codesign...");
1113
1114
String rcodesign = EDITOR_GET("export/macos/rcodesign").operator String();
1115
if (rcodesign.is_empty()) {
1116
add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("Xrcodesign path is not set. Configure rcodesign path in the Editor Settings (Export > macOS > rcodesign)."));
1117
return;
1118
}
1119
1120
List<String> args;
1121
args.push_back("sign");
1122
1123
if (!p_ent_path.is_empty()) {
1124
args.push_back("--entitlements-xml-path");
1125
args.push_back(p_ent_path);
1126
}
1127
1128
String certificate_file = p_preset->get_or_env("codesign/certificate_file", ENV_MAC_CODESIGN_CERT_FILE);
1129
String certificate_pass = p_preset->get_or_env("codesign/certificate_password", ENV_MAC_CODESIGN_CERT_PASS);
1130
if (!certificate_file.is_empty() && !certificate_pass.is_empty()) {
1131
args.push_back("--p12-file");
1132
args.push_back(certificate_file);
1133
args.push_back("--p12-password");
1134
args.push_back(certificate_pass);
1135
}
1136
args.push_back("--code-signature-flags");
1137
args.push_back("runtime");
1138
1139
if (p_set_id) {
1140
String app_id = p_preset->get("application/bundle_identifier");
1141
args.push_back("--binary-identifier");
1142
args.push_back(app_id);
1143
}
1144
1145
args.push_back("-v"); /* provide some more feedback */
1146
1147
args.push_back(p_path);
1148
1149
String str;
1150
int exitcode = 0;
1151
1152
Error err = OS::get_singleton()->execute(rcodesign, args, &str, &exitcode, true);
1153
if (err != OK) {
1154
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Could not start rcodesign executable."));
1155
return;
1156
}
1157
1158
if (exitcode != 0) {
1159
print_line("rcodesign (" + p_path + "):\n" + str);
1160
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Code signing failed, see editor log for details."));
1161
return;
1162
} else {
1163
print_verbose("rcodesign (" + p_path + "):\n" + str);
1164
}
1165
} break;
1166
#ifdef MACOS_ENABLED
1167
case 3: { // "codesign"
1168
print_verbose("using xcode codesign...");
1169
1170
if (!FileAccess::exists("/usr/bin/codesign") && !FileAccess::exists("/bin/codesign")) {
1171
add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("Xcode command line tools are not installed."));
1172
return;
1173
}
1174
1175
bool ad_hoc = (p_preset->get("codesign/identity") == "" || p_preset->get("codesign/identity") == "-");
1176
1177
List<String> args;
1178
if (!ad_hoc) {
1179
args.push_back("--timestamp");
1180
args.push_back("--options");
1181
args.push_back("runtime");
1182
}
1183
1184
if (!p_ent_path.is_empty()) {
1185
args.push_back("--entitlements");
1186
args.push_back(p_ent_path);
1187
}
1188
1189
PackedStringArray user_args = p_preset->get("codesign/custom_options");
1190
for (int i = 0; i < user_args.size(); i++) {
1191
String user_arg = user_args[i].strip_edges();
1192
if (!user_arg.is_empty()) {
1193
args.push_back(user_arg);
1194
}
1195
}
1196
1197
args.push_back("-s");
1198
if (ad_hoc) {
1199
args.push_back("-");
1200
} else {
1201
args.push_back(p_preset->get("codesign/identity"));
1202
}
1203
1204
if (p_set_id) {
1205
String app_id = p_preset->get("application/bundle_identifier");
1206
args.push_back("-i");
1207
args.push_back(app_id);
1208
}
1209
1210
args.push_back("-v"); /* provide some more feedback */
1211
args.push_back("-f");
1212
1213
args.push_back(p_path);
1214
1215
String str;
1216
int exitcode = 0;
1217
1218
Error err = OS::get_singleton()->execute("codesign", args, &str, &exitcode, true);
1219
if (err != OK) {
1220
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Could not start codesign executable, make sure Xcode command line tools are installed."));
1221
return;
1222
}
1223
1224
if (exitcode != 0) {
1225
print_line("codesign (" + p_path + "):\n" + str);
1226
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Code signing failed, see editor log for details."));
1227
return;
1228
} else {
1229
print_verbose("codesign (" + p_path + "):\n" + str);
1230
}
1231
} break;
1232
#endif
1233
default: {
1234
};
1235
}
1236
}
1237
1238
void EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPreset> &p_preset, const String &p_path,
1239
const String &p_ent_path, const String &p_helper_ent_path, bool p_should_error_on_non_code) {
1240
static Vector<String> extensions_to_sign;
1241
1242
bool sandbox = p_preset->get("codesign/entitlements/app_sandbox/enabled");
1243
if (extensions_to_sign.is_empty()) {
1244
extensions_to_sign.push_back("dylib");
1245
extensions_to_sign.push_back("framework");
1246
extensions_to_sign.push_back("");
1247
}
1248
1249
Error dir_access_error;
1250
Ref<DirAccess> dir_access{ DirAccess::open(p_path, &dir_access_error) };
1251
1252
if (dir_access_error != OK) {
1253
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Cannot sign directory %s."), p_path));
1254
return;
1255
}
1256
1257
dir_access->list_dir_begin();
1258
String current_file{ dir_access->get_next() };
1259
while (!current_file.is_empty()) {
1260
String current_file_path{ p_path.path_join(current_file) };
1261
1262
if (current_file == ".." || current_file == ".") {
1263
current_file = dir_access->get_next();
1264
continue;
1265
}
1266
1267
if (extensions_to_sign.has(current_file.get_extension())) {
1268
String ent_path;
1269
bool set_bundle_id = false;
1270
if (sandbox && FileAccess::exists(current_file_path)) {
1271
int ftype = MachO::get_filetype(current_file_path);
1272
if (ftype == 2 || ftype == 5) {
1273
ent_path = p_helper_ent_path;
1274
set_bundle_id = true;
1275
}
1276
}
1277
_code_sign(p_preset, current_file_path, ent_path, false, set_bundle_id);
1278
if (is_executable(current_file_path)) {
1279
// chmod with 0755 if the file is executable.
1280
FileAccess::set_unix_permissions(current_file_path, 0755);
1281
}
1282
} else if (dir_access->current_is_dir()) {
1283
_code_sign_directory(p_preset, current_file_path, p_ent_path, p_helper_ent_path, p_should_error_on_non_code);
1284
} else if (p_should_error_on_non_code) {
1285
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Cannot sign file %s."), current_file));
1286
}
1287
1288
current_file = dir_access->get_next();
1289
}
1290
}
1291
1292
Error EditorExportPlatformMacOS::_copy_and_sign_files(Ref<DirAccess> &dir_access, const String &p_src_path,
1293
const String &p_in_app_path, bool p_sign_enabled,
1294
const Ref<EditorExportPreset> &p_preset, const String &p_ent_path,
1295
const String &p_helper_ent_path,
1296
bool p_should_error_on_non_code_sign, bool p_sandbox) {
1297
static Vector<String> extensions_to_sign;
1298
1299
if (extensions_to_sign.is_empty()) {
1300
extensions_to_sign.push_back("dylib");
1301
extensions_to_sign.push_back("framework");
1302
extensions_to_sign.push_back("");
1303
}
1304
1305
Error err{ OK };
1306
if (dir_access->dir_exists(p_src_path)) {
1307
#ifndef UNIX_ENABLED
1308
add_message(EXPORT_MESSAGE_INFO, TTR("Export"), vformat(TTR("Relative symlinks are not supported, exported \"%s\" might be broken!"), p_src_path.get_file()));
1309
#endif
1310
print_verbose("export framework: " + p_src_path + " -> " + p_in_app_path);
1311
1312
bool plist_missing = false;
1313
Ref<PList> plist;
1314
plist.instantiate();
1315
plist->load_file(p_src_path.path_join("Resources").path_join("Info.plist"));
1316
1317
Ref<PListNode> root_node = plist->get_root();
1318
if (root_node.is_null()) {
1319
plist_missing = true;
1320
} else {
1321
Dictionary root = root_node->get_value();
1322
if (!root.has("CFBundleExecutable") || !root.has("CFBundleIdentifier") || !root.has("CFBundlePackageType") || !root.has("CFBundleInfoDictionaryVersion") || !root.has("CFBundleName") || !root.has("CFBundleSupportedPlatforms")) {
1323
plist_missing = true;
1324
}
1325
}
1326
1327
err = dir_access->make_dir_recursive(p_in_app_path);
1328
if (err == OK) {
1329
err = dir_access->copy_dir(p_src_path, p_in_app_path, -1, true);
1330
}
1331
if (err == OK && plist_missing) {
1332
add_message(EXPORT_MESSAGE_WARNING, TTR("Export"), vformat(TTR("\"%s\": Info.plist missing or invalid, new Info.plist generated."), p_src_path.get_file()));
1333
// Generate Info.plist
1334
String lib_name = p_src_path.get_basename().get_file();
1335
String lib_id = p_preset->get("application/bundle_identifier");
1336
String lib_clean_name = lib_name;
1337
for (int i = 0; i < lib_clean_name.length(); i++) {
1338
if (!is_ascii_alphanumeric_char(lib_clean_name[i]) && lib_clean_name[i] != '.' && lib_clean_name[i] != '-') {
1339
lib_clean_name[i] = '-';
1340
}
1341
}
1342
1343
String info_plist_format = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1344
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
1345
"<plist version=\"1.0\">\n"
1346
" <dict>\n"
1347
" <key>CFBundleExecutable</key>\n"
1348
" <string>$name</string>\n"
1349
" <key>CFBundleIdentifier</key>\n"
1350
" <string>$id.framework.$cl_name</string>\n"
1351
" <key>CFBundleInfoDictionaryVersion</key>\n"
1352
" <string>6.0</string>\n"
1353
" <key>CFBundleName</key>\n"
1354
" <string>$name</string>\n"
1355
" <key>CFBundlePackageType</key>\n"
1356
" <string>FMWK</string>\n"
1357
" <key>CFBundleShortVersionString</key>\n"
1358
" <string>1.0.0</string>\n"
1359
" <key>CFBundleSupportedPlatforms</key>\n"
1360
" <array>\n"
1361
" <string>MacOSX</string>\n"
1362
" </array>\n"
1363
" <key>CFBundleVersion</key>\n"
1364
" <string>1.0.0</string>\n"
1365
" <key>LSMinimumSystemVersion</key>\n"
1366
" <string>10.12</string>\n"
1367
" </dict>\n"
1368
"</plist>";
1369
1370
String info_plist = info_plist_format.replace("$id", lib_id).replace("$name", lib_name).replace("$cl_name", lib_clean_name);
1371
1372
err = dir_access->make_dir_recursive(p_in_app_path.path_join("Resources"));
1373
Ref<FileAccess> f = FileAccess::open(p_in_app_path.path_join("Resources").path_join("Info.plist"), FileAccess::WRITE);
1374
if (f.is_valid()) {
1375
f->store_string(info_plist);
1376
}
1377
}
1378
} else {
1379
print_verbose("export dylib: " + p_src_path + " -> " + p_in_app_path);
1380
err = dir_access->copy(p_src_path, p_in_app_path);
1381
}
1382
if (err == OK && p_sign_enabled) {
1383
if (dir_access->dir_exists(p_src_path) && p_src_path.get_extension().is_empty()) {
1384
// If it is a directory, find and sign all dynamic libraries.
1385
_code_sign_directory(p_preset, p_in_app_path, p_ent_path, p_helper_ent_path, p_should_error_on_non_code_sign);
1386
} else {
1387
if (extensions_to_sign.has(p_in_app_path.get_extension())) {
1388
String ent_path;
1389
bool set_bundle_id = false;
1390
if (p_sandbox && FileAccess::exists(p_in_app_path)) {
1391
int ftype = MachO::get_filetype(p_in_app_path);
1392
if (ftype == 2 || ftype == 5) {
1393
ent_path = p_helper_ent_path;
1394
set_bundle_id = true;
1395
}
1396
}
1397
_code_sign(p_preset, p_in_app_path, ent_path, false, set_bundle_id);
1398
}
1399
if (dir_access->file_exists(p_in_app_path) && is_executable(p_in_app_path)) {
1400
// chmod with 0755 if the file is executable.
1401
FileAccess::set_unix_permissions(p_in_app_path, 0755);
1402
}
1403
}
1404
}
1405
return err;
1406
}
1407
1408
Error EditorExportPlatformMacOS::_export_macos_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin,
1409
const String &p_app_path_name, Ref<DirAccess> &dir_access,
1410
bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset,
1411
const String &p_ent_path, const String &p_helper_ent_path, bool p_sandbox) {
1412
Error error{ OK };
1413
const Vector<String> &macos_plugins{ p_editor_export_plugin->get_macos_plugin_files() };
1414
for (int i = 0; i < macos_plugins.size(); ++i) {
1415
String src_path{ ProjectSettings::get_singleton()->globalize_path(macos_plugins[i]) };
1416
String path_in_app{ p_app_path_name + "/Contents/PlugIns/" + src_path.get_file() };
1417
error = _copy_and_sign_files(dir_access, src_path, path_in_app, p_sign_enabled, p_preset, p_ent_path, p_helper_ent_path, false, p_sandbox);
1418
if (error != OK) {
1419
break;
1420
}
1421
}
1422
return error;
1423
}
1424
1425
Error EditorExportPlatformMacOS::_create_pkg(const Ref<EditorExportPreset> &p_preset, const String &p_pkg_path, const String &p_app_path_name) {
1426
List<String> args;
1427
1428
if (FileAccess::exists(p_pkg_path)) {
1429
OS::get_singleton()->move_to_trash(p_pkg_path);
1430
}
1431
1432
args.push_back("productbuild");
1433
args.push_back("--component");
1434
args.push_back(p_app_path_name);
1435
args.push_back("/Applications");
1436
String ident = p_preset->get("codesign/installer_identity");
1437
if (!ident.is_empty()) {
1438
args.push_back("--timestamp");
1439
args.push_back("--sign");
1440
args.push_back(ident);
1441
}
1442
args.push_back("--quiet");
1443
args.push_back(p_pkg_path);
1444
1445
String str;
1446
Error err = OS::get_singleton()->execute("xcrun", args, &str, nullptr, true);
1447
if (err != OK) {
1448
add_message(EXPORT_MESSAGE_ERROR, TTR("PKG Creation"), TTR("Could not start productbuild executable."));
1449
return err;
1450
}
1451
1452
print_verbose("productbuild returned: " + str);
1453
if (str.contains("productbuild: error:")) {
1454
add_message(EXPORT_MESSAGE_ERROR, TTR("PKG Creation"), TTR("`productbuild` failed."));
1455
return FAILED;
1456
}
1457
1458
return OK;
1459
}
1460
1461
Error EditorExportPlatformMacOS::_create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name) {
1462
List<String> args;
1463
1464
if (FileAccess::exists(p_dmg_path)) {
1465
OS::get_singleton()->move_to_trash(p_dmg_path);
1466
}
1467
1468
args.push_back("create");
1469
args.push_back(p_dmg_path);
1470
args.push_back("-volname");
1471
args.push_back(p_pkg_name);
1472
args.push_back("-fs");
1473
args.push_back("HFS+");
1474
args.push_back("-srcfolder");
1475
args.push_back(p_app_path_name);
1476
1477
String str;
1478
Error err = OS::get_singleton()->execute("hdiutil", args, &str, nullptr, true);
1479
if (err != OK) {
1480
add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("Could not start hdiutil executable."));
1481
return err;
1482
}
1483
1484
print_verbose("hdiutil returned: " + str);
1485
if (str.contains("create failed")) {
1486
if (str.contains("File exists")) {
1487
add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("`hdiutil create` failed - file exists."));
1488
} else {
1489
add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("`hdiutil create` failed."));
1490
}
1491
return FAILED;
1492
}
1493
1494
return OK;
1495
}
1496
1497
bool EditorExportPlatformMacOS::is_shebang(const String &p_path) const {
1498
Ref<FileAccess> fb = FileAccess::open(p_path, FileAccess::READ);
1499
ERR_FAIL_COND_V_MSG(fb.is_null(), false, vformat("Can't open file: \"%s\".", p_path));
1500
uint16_t magic = fb->get_16();
1501
return (magic == 0x2123);
1502
}
1503
1504
bool EditorExportPlatformMacOS::is_executable(const String &p_path) const {
1505
return MachO::is_macho(p_path) || LipO::is_lipo(p_path) || is_shebang(p_path);
1506
}
1507
1508
Error EditorExportPlatformMacOS::_export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path) {
1509
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE);
1510
if (f.is_null()) {
1511
add_message(EXPORT_MESSAGE_ERROR, TTR("Debug Script Export"), vformat(TTR("Could not open file \"%s\"."), p_path));
1512
return ERR_CANT_CREATE;
1513
}
1514
1515
f->store_line("#!/bin/sh");
1516
f->store_line("printf '\\033c\\033]0;%s\\a' " + p_app_name);
1517
f->store_line("");
1518
f->store_line("function app_realpath() {");
1519
f->store_line(" SOURCE=$1");
1520
f->store_line(" while [ -h \"$SOURCE\" ]; do");
1521
f->store_line(" DIR=$(dirname \"$SOURCE\")");
1522
f->store_line(" SOURCE=$(readlink \"$SOURCE\")");
1523
f->store_line(" [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE");
1524
f->store_line(" done");
1525
f->store_line(" echo \"$( cd -P \"$( dirname \"$SOURCE\" )\" >/dev/null 2>&1 && pwd )\"");
1526
f->store_line("}");
1527
f->store_line("");
1528
f->store_line("BASE_PATH=\"$(app_realpath \"${BASH_SOURCE[0]}\")\"");
1529
f->store_line("\"$BASE_PATH/" + p_pkg_name + "\" \"$@\"");
1530
f->store_line("");
1531
1532
return OK;
1533
}
1534
1535
Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags) {
1536
ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
1537
1538
const String base_dir = p_path.get_base_dir();
1539
1540
if (!DirAccess::exists(base_dir)) {
1541
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Target folder does not exist or is inaccessible: \"%s\""), base_dir));
1542
return ERR_FILE_BAD_PATH;
1543
}
1544
1545
EditorProgress ep("export", TTR("Exporting for macOS"), 3, true);
1546
1547
String src_pkg_name;
1548
if (p_debug) {
1549
src_pkg_name = p_preset->get("custom_template/debug");
1550
} else {
1551
src_pkg_name = p_preset->get("custom_template/release");
1552
}
1553
1554
if (src_pkg_name.is_empty()) {
1555
String err;
1556
src_pkg_name = find_export_template("macos.zip", &err);
1557
if (src_pkg_name.is_empty()) {
1558
add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), TTR("Export template not found.") + "\n" + err);
1559
return ERR_FILE_NOT_FOUND;
1560
}
1561
}
1562
1563
Ref<FileAccess> io_fa;
1564
zlib_filefunc_def io = zipio_create_io(&io_fa);
1565
1566
if (ep.step(TTR("Creating app bundle"), 0)) {
1567
return ERR_SKIP;
1568
}
1569
1570
unzFile src_pkg_zip = unzOpen2(src_pkg_name.utf8().get_data(), &io);
1571
if (!src_pkg_zip) {
1572
add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Could not find template app to export: \"%s\"."), src_pkg_name));
1573
return ERR_FILE_NOT_FOUND;
1574
}
1575
1576
int ret = unzGoToFirstFile(src_pkg_zip);
1577
1578
String architecture = p_preset->get("binary_format/architecture");
1579
String binary_to_use = "godot_macos_" + String(p_debug ? "debug" : "release") + "." + architecture;
1580
1581
String pkg_name;
1582
if (String(get_project_setting(p_preset, "application/config/name")) != "") {
1583
pkg_name = String(get_project_setting(p_preset, "application/config/name"));
1584
} else {
1585
pkg_name = "Unnamed";
1586
}
1587
pkg_name = OS::get_singleton()->get_safe_dir_name(pkg_name);
1588
1589
String export_format;
1590
if (p_path.ends_with("zip")) {
1591
export_format = "zip";
1592
} else if (p_path.ends_with("app")) {
1593
export_format = "app";
1594
#ifdef MACOS_ENABLED
1595
} else if (p_path.ends_with("dmg")) {
1596
export_format = "dmg";
1597
} else if (p_path.ends_with("pkg")) {
1598
export_format = "pkg";
1599
#endif
1600
} else {
1601
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Invalid export format."));
1602
return ERR_CANT_CREATE;
1603
}
1604
1605
// Create our application bundle.
1606
String tmp_app_dir_name = pkg_name + ".app";
1607
String tmp_base_path_name;
1608
String tmp_app_path_name;
1609
String scr_path;
1610
if (export_format == "app") {
1611
tmp_base_path_name = p_path.get_base_dir();
1612
tmp_app_path_name = p_path;
1613
scr_path = p_path.get_basename() + ".command";
1614
} else {
1615
tmp_base_path_name = EditorPaths::get_singleton()->get_temp_dir().path_join(pkg_name);
1616
tmp_app_path_name = tmp_base_path_name.path_join(tmp_app_dir_name);
1617
scr_path = tmp_base_path_name.path_join(pkg_name + ".command");
1618
}
1619
1620
print_verbose("Exporting to " + tmp_app_path_name);
1621
1622
Error err = OK;
1623
1624
Ref<DirAccess> tmp_app_dir = DirAccess::create_for_path(tmp_base_path_name);
1625
if (tmp_app_dir.is_null()) {
1626
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory: \"%s\"."), tmp_base_path_name));
1627
err = ERR_CANT_CREATE;
1628
}
1629
1630
if (FileAccess::exists(scr_path)) {
1631
DirAccess::remove_file_or_error(scr_path);
1632
}
1633
if (DirAccess::exists(tmp_app_path_name)) {
1634
String old_dir = tmp_app_dir->get_current_dir();
1635
if (tmp_app_dir->change_dir(tmp_app_path_name) == OK) {
1636
tmp_app_dir->erase_contents_recursive();
1637
tmp_app_dir->change_dir(old_dir);
1638
}
1639
}
1640
1641
Array helpers = p_preset->get("codesign/entitlements/app_sandbox/helper_executables");
1642
1643
// Create our folder structure.
1644
if (err == OK) {
1645
print_verbose("Creating " + tmp_app_path_name + "/Contents/MacOS");
1646
err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/MacOS");
1647
if (err != OK) {
1648
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), tmp_app_path_name + "/Contents/MacOS"));
1649
}
1650
}
1651
1652
if (err == OK) {
1653
print_verbose("Creating " + tmp_app_path_name + "/Contents/Frameworks");
1654
err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/Frameworks");
1655
if (err != OK) {
1656
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), tmp_app_path_name + "/Contents/Frameworks"));
1657
}
1658
}
1659
1660
if ((err == OK) && helpers.size() > 0) {
1661
print_line("Creating " + tmp_app_path_name + "/Contents/Helpers");
1662
err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/Helpers");
1663
if (err != OK) {
1664
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), tmp_app_path_name + "/Contents/Helpers"));
1665
}
1666
}
1667
1668
if (err == OK) {
1669
print_verbose("Creating " + tmp_app_path_name + "/Contents/Resources");
1670
err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/Resources");
1671
if (err != OK) {
1672
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), tmp_app_path_name + "/Contents/Resources"));
1673
}
1674
}
1675
1676
Dictionary appnames = get_project_setting(p_preset, "application/config/name_localized");
1677
Dictionary microphone_usage_descriptions = p_preset->get("privacy/microphone_usage_description_localized");
1678
Dictionary camera_usage_descriptions = p_preset->get("privacy/camera_usage_description_localized");
1679
Dictionary location_usage_descriptions = p_preset->get("privacy/location_usage_description_localized");
1680
Dictionary address_book_usage_descriptions = p_preset->get("privacy/address_book_usage_description_localized");
1681
Dictionary calendar_usage_descriptions = p_preset->get("privacy/calendar_usage_description_localized");
1682
Dictionary photos_library_usage_descriptions = p_preset->get("privacy/photos_library_usage_description_localized");
1683
Dictionary desktop_folder_usage_descriptions = p_preset->get("privacy/desktop_folder_usage_description_localized");
1684
Dictionary documents_folder_usage_descriptions = p_preset->get("privacy/documents_folder_usage_description_localized");
1685
Dictionary downloads_folder_usage_descriptions = p_preset->get("privacy/downloads_folder_usage_description_localized");
1686
Dictionary network_volumes_usage_descriptions = p_preset->get("privacy/network_volumes_usage_description_localized");
1687
Dictionary removable_volumes_usage_descriptions = p_preset->get("privacy/removable_volumes_usage_description_localized");
1688
Dictionary copyrights = p_preset->get("application/copyright_localized");
1689
1690
Vector<String> translations = get_project_setting(p_preset, "internationalization/locale/translations");
1691
if (translations.size() > 0) {
1692
{
1693
String fname = tmp_app_path_name + "/Contents/Resources/en.lproj";
1694
tmp_app_dir->make_dir_recursive(fname);
1695
Ref<FileAccess> f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE);
1696
f->store_line("/* Localized versions of Info.plist keys */");
1697
f->store_line("");
1698
f->store_line("CFBundleDisplayName = \"" + get_project_setting(p_preset, "application/config/name").operator String() + "\";");
1699
if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) {
1700
f->store_line("NSMicrophoneUsageDescription = \"" + p_preset->get("privacy/microphone_usage_description").operator String() + "\";");
1701
}
1702
if (!((String)p_preset->get("privacy/camera_usage_description")).is_empty()) {
1703
f->store_line("NSCameraUsageDescription = \"" + p_preset->get("privacy/camera_usage_description").operator String() + "\";");
1704
}
1705
if (!((String)p_preset->get("privacy/location_usage_description")).is_empty()) {
1706
f->store_line("NSLocationUsageDescription = \"" + p_preset->get("privacy/location_usage_description").operator String() + "\";");
1707
}
1708
if (!((String)p_preset->get("privacy/address_book_usage_description")).is_empty()) {
1709
f->store_line("NSContactsUsageDescription = \"" + p_preset->get("privacy/address_book_usage_description").operator String() + "\";");
1710
}
1711
if (!((String)p_preset->get("privacy/calendar_usage_description")).is_empty()) {
1712
f->store_line("NSCalendarsUsageDescription = \"" + p_preset->get("privacy/calendar_usage_description").operator String() + "\";");
1713
}
1714
if (!((String)p_preset->get("privacy/photos_library_usage_description")).is_empty()) {
1715
f->store_line("NSPhotoLibraryUsageDescription = \"" + p_preset->get("privacy/photos_library_usage_description").operator String() + "\";");
1716
}
1717
if (!((String)p_preset->get("privacy/desktop_folder_usage_description")).is_empty()) {
1718
f->store_line("NSDesktopFolderUsageDescription = \"" + p_preset->get("privacy/desktop_folder_usage_description").operator String() + "\";");
1719
}
1720
if (!((String)p_preset->get("privacy/documents_folder_usage_description")).is_empty()) {
1721
f->store_line("NSDocumentsFolderUsageDescription = \"" + p_preset->get("privacy/documents_folder_usage_description").operator String() + "\";");
1722
}
1723
if (!((String)p_preset->get("privacy/downloads_folder_usage_description")).is_empty()) {
1724
f->store_line("NSDownloadsFolderUsageDescription = \"" + p_preset->get("privacy/downloads_folder_usage_description").operator String() + "\";");
1725
}
1726
if (!((String)p_preset->get("privacy/network_volumes_usage_description")).is_empty()) {
1727
f->store_line("NSNetworkVolumesUsageDescription = \"" + p_preset->get("privacy/network_volumes_usage_description").operator String() + "\";");
1728
}
1729
if (!((String)p_preset->get("privacy/removable_volumes_usage_description")).is_empty()) {
1730
f->store_line("NSRemovableVolumesUsageDescription = \"" + p_preset->get("privacy/removable_volumes_usage_description").operator String() + "\";");
1731
}
1732
f->store_line("NSHumanReadableCopyright = \"" + p_preset->get("application/copyright").operator String() + "\";");
1733
}
1734
1735
HashSet<String> languages;
1736
for (const String &E : translations) {
1737
Ref<Translation> tr = ResourceLoader::load(E);
1738
if (tr.is_valid() && tr->get_locale() != "en") {
1739
languages.insert(tr->get_locale());
1740
}
1741
}
1742
1743
for (const String &lang : languages) {
1744
String fname = tmp_app_path_name + "/Contents/Resources/" + lang + ".lproj";
1745
tmp_app_dir->make_dir_recursive(fname);
1746
Ref<FileAccess> f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE);
1747
f->store_line("/* Localized versions of Info.plist keys */");
1748
f->store_line("");
1749
if (appnames.has(lang)) {
1750
f->store_line("CFBundleDisplayName = \"" + appnames[lang].operator String() + "\";");
1751
}
1752
if (microphone_usage_descriptions.has(lang)) {
1753
f->store_line("NSMicrophoneUsageDescription = \"" + microphone_usage_descriptions[lang].operator String() + "\";");
1754
}
1755
if (camera_usage_descriptions.has(lang)) {
1756
f->store_line("NSCameraUsageDescription = \"" + camera_usage_descriptions[lang].operator String() + "\";");
1757
}
1758
if (location_usage_descriptions.has(lang)) {
1759
f->store_line("NSLocationUsageDescription = \"" + location_usage_descriptions[lang].operator String() + "\";");
1760
}
1761
if (address_book_usage_descriptions.has(lang)) {
1762
f->store_line("NSContactsUsageDescription = \"" + address_book_usage_descriptions[lang].operator String() + "\";");
1763
}
1764
if (calendar_usage_descriptions.has(lang)) {
1765
f->store_line("NSCalendarsUsageDescription = \"" + calendar_usage_descriptions[lang].operator String() + "\";");
1766
}
1767
if (photos_library_usage_descriptions.has(lang)) {
1768
f->store_line("NSPhotoLibraryUsageDescription = \"" + photos_library_usage_descriptions[lang].operator String() + "\";");
1769
}
1770
if (desktop_folder_usage_descriptions.has(lang)) {
1771
f->store_line("NSDesktopFolderUsageDescription = \"" + desktop_folder_usage_descriptions[lang].operator String() + "\";");
1772
}
1773
if (documents_folder_usage_descriptions.has(lang)) {
1774
f->store_line("NSDocumentsFolderUsageDescription = \"" + documents_folder_usage_descriptions[lang].operator String() + "\";");
1775
}
1776
if (downloads_folder_usage_descriptions.has(lang)) {
1777
f->store_line("NSDownloadsFolderUsageDescription = \"" + downloads_folder_usage_descriptions[lang].operator String() + "\";");
1778
}
1779
if (network_volumes_usage_descriptions.has(lang)) {
1780
f->store_line("NSNetworkVolumesUsageDescription = \"" + network_volumes_usage_descriptions[lang].operator String() + "\";");
1781
}
1782
if (removable_volumes_usage_descriptions.has(lang)) {
1783
f->store_line("NSRemovableVolumesUsageDescription = \"" + removable_volumes_usage_descriptions[lang].operator String() + "\";");
1784
}
1785
if (copyrights.has(lang)) {
1786
f->store_line("NSHumanReadableCopyright = \"" + copyrights[lang].operator String() + "\";");
1787
}
1788
}
1789
}
1790
1791
// Now process our template.
1792
bool found_binary = false;
1793
1794
int export_angle = p_preset->get("application/export_angle");
1795
bool include_angle_libs = false;
1796
if (export_angle == 0) {
1797
include_angle_libs = String(get_project_setting(p_preset, "rendering/gl_compatibility/driver.macos")) == "opengl3_angle";
1798
} else if (export_angle == 1) {
1799
include_angle_libs = true;
1800
}
1801
1802
while (ret == UNZ_OK && err == OK) {
1803
// Get filename.
1804
unz_file_info info;
1805
char fname[16384];
1806
ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, nullptr, 0, nullptr, 0);
1807
if (ret != UNZ_OK) {
1808
break;
1809
}
1810
1811
String file = String::utf8(fname);
1812
1813
Vector<uint8_t> data;
1814
data.resize(info.uncompressed_size);
1815
1816
// Read.
1817
unzOpenCurrentFile(src_pkg_zip);
1818
unzReadCurrentFile(src_pkg_zip, data.ptrw(), data.size());
1819
unzCloseCurrentFile(src_pkg_zip);
1820
1821
// Write.
1822
file = file.replace_first("macos_template.app/", "");
1823
1824
if (((info.external_fa >> 16L) & 0120000) == 0120000) {
1825
#ifndef UNIX_ENABLED
1826
add_message(EXPORT_MESSAGE_INFO, TTR("Export"), TTR("Relative symlinks are not supported on this OS, the exported project might be broken!"));
1827
#endif
1828
// Handle symlinks in the archive.
1829
file = tmp_app_path_name.path_join(file);
1830
if (err == OK) {
1831
err = tmp_app_dir->make_dir_recursive(file.get_base_dir());
1832
if (err != OK) {
1833
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), file.get_base_dir()));
1834
}
1835
}
1836
if (err == OK) {
1837
String lnk_data = String::utf8((const char *)data.ptr(), data.size());
1838
err = tmp_app_dir->create_link(lnk_data, file);
1839
if (err != OK) {
1840
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not created symlink \"%s\" -> \"%s\"."), lnk_data, file));
1841
}
1842
print_verbose(vformat("ADDING SYMLINK %s => %s\n", file, lnk_data));
1843
}
1844
1845
ret = unzGoToNextFile(src_pkg_zip);
1846
continue; // next
1847
}
1848
1849
if (file == "Contents/Frameworks/libEGL.dylib") {
1850
if (!include_angle_libs) {
1851
ret = unzGoToNextFile(src_pkg_zip);
1852
continue; // skip
1853
}
1854
}
1855
1856
if (file == "Contents/Frameworks/libGLESv2.dylib") {
1857
if (!include_angle_libs) {
1858
ret = unzGoToNextFile(src_pkg_zip);
1859
continue; // skip
1860
}
1861
}
1862
1863
if (file == "Contents/Info.plist") {
1864
_fix_plist(p_preset, data, pkg_name);
1865
}
1866
1867
if (file == "Contents/Resources/PrivacyInfo.xcprivacy") {
1868
_fix_privacy_manifest(p_preset, data);
1869
}
1870
1871
if (file.begins_with("Contents/MacOS/godot_")) {
1872
if (file != "Contents/MacOS/" + binary_to_use) {
1873
ret = unzGoToNextFile(src_pkg_zip);
1874
continue; // skip
1875
}
1876
found_binary = true;
1877
file = "Contents/MacOS/" + pkg_name;
1878
}
1879
1880
if (file == "Contents/Resources/icon.icns") {
1881
// See if there is an icon.
1882
String icon_path;
1883
if (p_preset->get("application/icon") != "") {
1884
icon_path = p_preset->get("application/icon");
1885
} else if (get_project_setting(p_preset, "application/config/macos_native_icon") != "") {
1886
icon_path = get_project_setting(p_preset, "application/config/macos_native_icon");
1887
} else {
1888
icon_path = get_project_setting(p_preset, "application/config/icon");
1889
}
1890
1891
if (!icon_path.is_empty()) {
1892
if (icon_path.get_extension() == "icns") {
1893
Ref<FileAccess> icon = FileAccess::open(icon_path, FileAccess::READ);
1894
if (icon.is_valid()) {
1895
data.resize(icon->get_length());
1896
icon->get_buffer(&data.write[0], icon->get_length());
1897
}
1898
} else {
1899
Ref<Image> icon = _load_icon_or_splash_image(icon_path, &err);
1900
if (err == OK && icon.is_valid() && !icon->is_empty()) {
1901
_make_icon(p_preset, icon, data);
1902
}
1903
}
1904
}
1905
}
1906
1907
if (data.size() > 0) {
1908
print_verbose("ADDING: " + file + " size: " + itos(data.size()));
1909
1910
// Write it into our application bundle.
1911
file = tmp_app_path_name.path_join(file);
1912
if (err == OK) {
1913
err = tmp_app_dir->make_dir_recursive(file.get_base_dir());
1914
if (err != OK) {
1915
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), file.get_base_dir()));
1916
}
1917
}
1918
if (err == OK) {
1919
Ref<FileAccess> f = FileAccess::open(file, FileAccess::WRITE);
1920
if (f.is_valid()) {
1921
f->store_buffer(data.ptr(), data.size());
1922
f.unref();
1923
if (is_executable(file)) {
1924
// chmod with 0755 if the file is executable.
1925
FileAccess::set_unix_permissions(file, 0755);
1926
#ifndef UNIX_ENABLED
1927
if (export_format == "app") {
1928
add_message(EXPORT_MESSAGE_INFO, TTR("Export"), vformat(TTR("Unable to set Unix permissions for executable \"%s\". Use \"chmod +x\" to set it after transferring the exported .app to macOS or Linux."), "Contents/MacOS/" + file.get_file()));
1929
}
1930
#endif
1931
}
1932
} else {
1933
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not open \"%s\"."), file));
1934
err = ERR_CANT_CREATE;
1935
}
1936
}
1937
}
1938
1939
ret = unzGoToNextFile(src_pkg_zip);
1940
}
1941
1942
// We're done with our source zip.
1943
unzClose(src_pkg_zip);
1944
1945
if (!found_binary) {
1946
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Requested template binary \"%s\" not found. It might be missing from your template archive."), binary_to_use));
1947
err = ERR_FILE_NOT_FOUND;
1948
}
1949
1950
// Save console wrapper.
1951
if (err == OK) {
1952
int con_scr = p_preset->get("debug/export_console_wrapper");
1953
if ((con_scr == 1 && p_debug) || (con_scr == 2)) {
1954
err = _export_debug_script(p_preset, pkg_name, tmp_app_path_name.get_file() + "/Contents/MacOS/" + pkg_name, scr_path);
1955
FileAccess::set_unix_permissions(scr_path, 0755);
1956
#ifndef UNIX_ENABLED
1957
if (export_format == "app") {
1958
add_message(EXPORT_MESSAGE_INFO, TTR("Export"), vformat(TTR("Unable to set Unix permissions for executable \"%s\". Use \"chmod +x\" to set it after transferring the exported .app to macOS or Linux."), scr_path.get_file()));
1959
}
1960
#endif
1961
if (err != OK) {
1962
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Could not create console wrapper."));
1963
}
1964
}
1965
}
1966
1967
if (err == OK) {
1968
if (ep.step(TTR("Making PKG"), 1)) {
1969
return ERR_SKIP;
1970
}
1971
1972
// See if we can code sign our new package.
1973
bool sign_enabled = (p_preset->get("codesign/codesign").operator int() > 0);
1974
bool ad_hoc = false;
1975
int codesign_tool = p_preset->get("codesign/codesign");
1976
switch (codesign_tool) {
1977
case 1: { // built-in ad-hoc
1978
ad_hoc = true;
1979
} break;
1980
case 2: { // "rcodesign"
1981
ad_hoc = p_preset->get_or_env("codesign/certificate_file", ENV_MAC_CODESIGN_CERT_FILE).operator String().is_empty() || p_preset->get_or_env("codesign/certificate_password", ENV_MAC_CODESIGN_CERT_PASS).operator String().is_empty();
1982
} break;
1983
#ifdef MACOS_ENABLED
1984
case 3: { // "codesign"
1985
ad_hoc = (p_preset->get("codesign/identity") == "" || p_preset->get("codesign/identity") == "-");
1986
} break;
1987
#endif
1988
default: {
1989
};
1990
}
1991
1992
String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck";
1993
Vector<SharedObject> shared_objects;
1994
err = save_pack(p_preset, p_debug, pack_path, &shared_objects);
1995
1996
bool lib_validation = p_preset->get("codesign/entitlements/disable_library_validation");
1997
if (!shared_objects.is_empty() && sign_enabled && ad_hoc && !lib_validation) {
1998
add_message(EXPORT_MESSAGE_INFO, TTR("Entitlements Modified"), TTR("Ad-hoc signed applications require the 'Disable Library Validation' entitlement to load dynamic libraries."));
1999
lib_validation = true;
2000
}
2001
2002
if (!shared_objects.is_empty() && sign_enabled && codesign_tool == 2) {
2003
add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("'rcodesign' doesn't support signing applications with embedded dynamic libraries."));
2004
}
2005
2006
bool sandbox = p_preset->get("codesign/entitlements/app_sandbox/enabled");
2007
String ent_path = p_preset->get("codesign/entitlements/custom_file");
2008
String hlp_ent_path = sandbox ? EditorPaths::get_singleton()->get_temp_dir().path_join(pkg_name + "_helper.entitlements") : ent_path;
2009
if (sign_enabled && (ent_path.is_empty())) {
2010
ent_path = EditorPaths::get_singleton()->get_temp_dir().path_join(pkg_name + ".entitlements");
2011
2012
Ref<FileAccess> ent_f = FileAccess::open(ent_path, FileAccess::WRITE);
2013
if (ent_f.is_valid()) {
2014
ent_f->store_line("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
2015
ent_f->store_line("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
2016
ent_f->store_line("<plist version=\"1.0\">");
2017
ent_f->store_line("<dict>");
2018
if (ClassDB::class_exists("CSharpScript")) {
2019
// These entitlements are required to run managed code, and are always enabled in Mono builds.
2020
ent_f->store_line("<key>com.apple.security.cs.allow-jit</key>");
2021
ent_f->store_line("<true/>");
2022
ent_f->store_line("<key>com.apple.security.cs.allow-unsigned-executable-memory</key>");
2023
ent_f->store_line("<true/>");
2024
ent_f->store_line("<key>com.apple.security.cs.allow-dyld-environment-variables</key>");
2025
ent_f->store_line("<true/>");
2026
} else {
2027
if ((bool)p_preset->get("codesign/entitlements/allow_jit_code_execution")) {
2028
ent_f->store_line("<key>com.apple.security.cs.allow-jit</key>");
2029
ent_f->store_line("<true/>");
2030
}
2031
if ((bool)p_preset->get("codesign/entitlements/allow_unsigned_executable_memory")) {
2032
ent_f->store_line("<key>com.apple.security.cs.allow-unsigned-executable-memory</key>");
2033
ent_f->store_line("<true/>");
2034
}
2035
if ((bool)p_preset->get("codesign/entitlements/allow_dyld_environment_variables")) {
2036
ent_f->store_line("<key>com.apple.security.cs.allow-dyld-environment-variables</key>");
2037
ent_f->store_line("<true/>");
2038
}
2039
}
2040
2041
if (lib_validation) {
2042
ent_f->store_line("<key>com.apple.security.cs.disable-library-validation</key>");
2043
ent_f->store_line("<true/>");
2044
}
2045
if ((bool)p_preset->get("codesign/entitlements/audio_input")) {
2046
ent_f->store_line("<key>com.apple.security.device.audio-input</key>");
2047
ent_f->store_line("<true/>");
2048
}
2049
if ((bool)p_preset->get("codesign/entitlements/camera")) {
2050
ent_f->store_line("<key>com.apple.security.device.camera</key>");
2051
ent_f->store_line("<true/>");
2052
}
2053
if ((bool)p_preset->get("codesign/entitlements/location")) {
2054
ent_f->store_line("<key>com.apple.security.personal-information.location</key>");
2055
ent_f->store_line("<true/>");
2056
}
2057
if ((bool)p_preset->get("codesign/entitlements/address_book")) {
2058
ent_f->store_line("<key>com.apple.security.personal-information.addressbook</key>");
2059
ent_f->store_line("<true/>");
2060
}
2061
if ((bool)p_preset->get("codesign/entitlements/calendars")) {
2062
ent_f->store_line("<key>com.apple.security.personal-information.calendars</key>");
2063
ent_f->store_line("<true/>");
2064
}
2065
if ((bool)p_preset->get("codesign/entitlements/photos_library")) {
2066
ent_f->store_line("<key>com.apple.security.personal-information.photos-library</key>");
2067
ent_f->store_line("<true/>");
2068
}
2069
if ((bool)p_preset->get("codesign/entitlements/apple_events")) {
2070
ent_f->store_line("<key>com.apple.security.automation.apple-events</key>");
2071
ent_f->store_line("<true/>");
2072
}
2073
if ((bool)p_preset->get("codesign/entitlements/debugging")) {
2074
ent_f->store_line("<key>com.apple.security.get-task-allow</key>");
2075
ent_f->store_line("<true/>");
2076
}
2077
2078
int dist_type = p_preset->get("export/distribution_type");
2079
if (dist_type == 2) {
2080
String pprof = p_preset->get_or_env("codesign/provisioning_profile", ENV_MAC_CODESIGN_PROFILE);
2081
String teamid = p_preset->get("codesign/apple_team_id");
2082
String bid = p_preset->get("application/bundle_identifier");
2083
if (!pprof.is_empty() && !teamid.is_empty()) {
2084
ent_f->store_line("<key>com.apple.developer.team-identifier</key>");
2085
ent_f->store_line("<string>" + teamid + "</string>");
2086
ent_f->store_line("<key>com.apple.application-identifier</key>");
2087
ent_f->store_line("<string>" + teamid + "." + bid + "</string>");
2088
}
2089
}
2090
2091
if ((bool)p_preset->get("codesign/entitlements/app_sandbox/enabled")) {
2092
ent_f->store_line("<key>com.apple.security.app-sandbox</key>");
2093
ent_f->store_line("<true/>");
2094
2095
if ((bool)p_preset->get("codesign/entitlements/app_sandbox/network_server")) {
2096
ent_f->store_line("<key>com.apple.security.network.server</key>");
2097
ent_f->store_line("<true/>");
2098
}
2099
if ((bool)p_preset->get("codesign/entitlements/app_sandbox/network_client")) {
2100
ent_f->store_line("<key>com.apple.security.network.client</key>");
2101
ent_f->store_line("<true/>");
2102
}
2103
if ((bool)p_preset->get("codesign/entitlements/app_sandbox/device_usb")) {
2104
ent_f->store_line("<key>com.apple.security.device.usb</key>");
2105
ent_f->store_line("<true/>");
2106
}
2107
if ((bool)p_preset->get("codesign/entitlements/app_sandbox/device_bluetooth")) {
2108
ent_f->store_line("<key>com.apple.security.device.bluetooth</key>");
2109
ent_f->store_line("<true/>");
2110
}
2111
if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_downloads") == 1) {
2112
ent_f->store_line("<key>com.apple.security.files.downloads.read-only</key>");
2113
ent_f->store_line("<true/>");
2114
}
2115
if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_downloads") == 2) {
2116
ent_f->store_line("<key>com.apple.security.files.downloads.read-write</key>");
2117
ent_f->store_line("<true/>");
2118
}
2119
if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_pictures") == 1) {
2120
ent_f->store_line("<key>com.apple.security.files.pictures.read-only</key>");
2121
ent_f->store_line("<true/>");
2122
}
2123
if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_pictures") == 2) {
2124
ent_f->store_line("<key>com.apple.security.files.pictures.read-write</key>");
2125
ent_f->store_line("<true/>");
2126
}
2127
if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_music") == 1) {
2128
ent_f->store_line("<key>com.apple.security.files.music.read-only</key>");
2129
ent_f->store_line("<true/>");
2130
}
2131
if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_music") == 2) {
2132
ent_f->store_line("<key>com.apple.security.files.music.read-write</key>");
2133
ent_f->store_line("<true/>");
2134
}
2135
if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_movies") == 1) {
2136
ent_f->store_line("<key>com.apple.security.files.movies.read-only</key>");
2137
ent_f->store_line("<true/>");
2138
}
2139
if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_movies") == 2) {
2140
ent_f->store_line("<key>com.apple.security.files.movies.read-write</key>");
2141
ent_f->store_line("<true/>");
2142
}
2143
if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_user_selected") == 1) {
2144
ent_f->store_line("<key>com.apple.security.files.user-selected.read-only</key>");
2145
ent_f->store_line("<true/>");
2146
}
2147
if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_user_selected") == 2) {
2148
ent_f->store_line("<key>com.apple.security.files.user-selected.read-write</key>");
2149
ent_f->store_line("<true/>");
2150
}
2151
}
2152
2153
const String &additional_entitlements = p_preset->get("codesign/entitlements/additional");
2154
if (!additional_entitlements.is_empty()) {
2155
ent_f->store_line(additional_entitlements);
2156
}
2157
2158
ent_f->store_line("</dict>");
2159
ent_f->store_line("</plist>");
2160
} else {
2161
add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("Could not create entitlements file."));
2162
err = ERR_CANT_CREATE;
2163
}
2164
2165
if ((err == OK) && sandbox && (helpers.size() > 0 || shared_objects.size() > 0)) {
2166
ent_f = FileAccess::open(hlp_ent_path, FileAccess::WRITE);
2167
if (ent_f.is_valid()) {
2168
ent_f->store_line("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
2169
ent_f->store_line("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
2170
ent_f->store_line("<plist version=\"1.0\">");
2171
ent_f->store_line("<dict>");
2172
ent_f->store_line("<key>com.apple.security.app-sandbox</key>");
2173
ent_f->store_line("<true/>");
2174
ent_f->store_line("<key>com.apple.security.inherit</key>");
2175
ent_f->store_line("<true/>");
2176
ent_f->store_line("</dict>");
2177
ent_f->store_line("</plist>");
2178
} else {
2179
add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("Could not create helper entitlements file."));
2180
err = ERR_CANT_CREATE;
2181
}
2182
}
2183
}
2184
2185
if ((err == OK) && helpers.size() > 0) {
2186
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
2187
for (int i = 0; i < helpers.size(); i++) {
2188
String hlp_path = helpers[i];
2189
err = da->copy(hlp_path, tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file());
2190
if (err == OK && sign_enabled) {
2191
_code_sign(p_preset, tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file(), hlp_ent_path, false, true);
2192
}
2193
FileAccess::set_unix_permissions(tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file(), 0755);
2194
#ifndef UNIX_ENABLED
2195
if (export_format == "app") {
2196
add_message(EXPORT_MESSAGE_INFO, TTR("Export"), vformat(TTR("Unable to set Unix permissions for executable \"%s\". Use \"chmod +x\" to set it after transferring the exported .app to macOS or Linux."), "Contents/Helpers/" + hlp_path.get_file()));
2197
}
2198
#endif
2199
}
2200
}
2201
2202
if (err == OK) {
2203
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
2204
for (int i = 0; i < shared_objects.size(); i++) {
2205
String src_path = ProjectSettings::get_singleton()->globalize_path(shared_objects[i].path);
2206
if (shared_objects[i].target.is_empty()) {
2207
String path_in_app = tmp_app_path_name + "/Contents/Frameworks/" + src_path.get_file();
2208
err = _copy_and_sign_files(da, src_path, path_in_app, sign_enabled, p_preset, ent_path, hlp_ent_path, true, sandbox);
2209
} else {
2210
String path_in_app = tmp_app_path_name.path_join(shared_objects[i].target);
2211
tmp_app_dir->make_dir_recursive(path_in_app);
2212
err = _copy_and_sign_files(da, src_path, path_in_app.path_join(src_path.get_file()), sign_enabled, p_preset, ent_path, hlp_ent_path, false, sandbox);
2213
}
2214
if (err != OK) {
2215
break;
2216
}
2217
}
2218
2219
Vector<Ref<EditorExportPlugin>> export_plugins{ EditorExport::get_singleton()->get_export_plugins() };
2220
for (int i = 0; i < export_plugins.size(); ++i) {
2221
err = _export_macos_plugins_for(export_plugins[i], tmp_app_path_name, da, sign_enabled, p_preset, ent_path, hlp_ent_path, sandbox);
2222
if (err != OK) {
2223
break;
2224
}
2225
}
2226
}
2227
2228
if (err == OK && sign_enabled) {
2229
int dist_type = p_preset->get("export/distribution_type");
2230
if (dist_type == 2) {
2231
String pprof = p_preset->get_or_env("codesign/provisioning_profile", ENV_MAC_CODESIGN_PROFILE).operator String();
2232
if (!pprof.is_empty()) {
2233
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
2234
err = da->copy(pprof, tmp_app_path_name + "/Contents/embedded.provisionprofile");
2235
}
2236
}
2237
2238
if (ep.step(TTR("Code signing bundle"), 2)) {
2239
return ERR_SKIP;
2240
}
2241
_code_sign(p_preset, tmp_app_path_name, ent_path, true, false);
2242
}
2243
2244
String noto_path = p_path;
2245
bool noto_enabled = (p_preset->get("notarization/notarization").operator int() > 0);
2246
if (export_format == "dmg") {
2247
// Create a DMG.
2248
if (err == OK) {
2249
if (ep.step(TTR("Making DMG"), 3)) {
2250
return ERR_SKIP;
2251
}
2252
err = _create_dmg(p_path, pkg_name, tmp_base_path_name);
2253
}
2254
// Sign DMG.
2255
if (err == OK && sign_enabled && !ad_hoc) {
2256
if (ep.step(TTR("Code signing DMG"), 3)) {
2257
return ERR_SKIP;
2258
}
2259
_code_sign(p_preset, p_path, ent_path, false, false);
2260
}
2261
} else if (export_format == "pkg") {
2262
// Create a Installer.
2263
if (err == OK) {
2264
if (ep.step(TTR("Making PKG installer"), 3)) {
2265
return ERR_SKIP;
2266
}
2267
err = _create_pkg(p_preset, p_path, tmp_app_path_name);
2268
}
2269
} else if (export_format == "zip") {
2270
// Create ZIP.
2271
if (err == OK) {
2272
if (ep.step(TTR("Making ZIP"), 3)) {
2273
return ERR_SKIP;
2274
}
2275
if (FileAccess::exists(p_path)) {
2276
OS::get_singleton()->move_to_trash(p_path);
2277
}
2278
2279
Ref<FileAccess> io_fa_dst;
2280
zlib_filefunc_def io_dst = zipio_create_io(&io_fa_dst);
2281
zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io_dst);
2282
2283
zip_folder_recursive(zip, tmp_base_path_name, "", pkg_name);
2284
2285
zipClose(zip, nullptr);
2286
}
2287
} else if (export_format == "app" && noto_enabled) {
2288
// Create temporary ZIP.
2289
if (err == OK) {
2290
noto_path = EditorPaths::get_singleton()->get_temp_dir().path_join(pkg_name + ".zip");
2291
2292
if (ep.step(TTR("Making ZIP"), 3)) {
2293
return ERR_SKIP;
2294
}
2295
if (FileAccess::exists(noto_path)) {
2296
OS::get_singleton()->move_to_trash(noto_path);
2297
}
2298
2299
Ref<FileAccess> io_fa_dst;
2300
zlib_filefunc_def io_dst = zipio_create_io(&io_fa_dst);
2301
zipFile zip = zipOpen2(noto_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io_dst);
2302
2303
zip_folder_recursive(zip, tmp_base_path_name, tmp_app_dir_name, pkg_name);
2304
2305
zipClose(zip, nullptr);
2306
}
2307
}
2308
2309
if (err == OK && noto_enabled) {
2310
if (export_format == "pkg") {
2311
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("Notarization requires the app to be archived first, select the DMG or ZIP export format instead."));
2312
} else {
2313
if (ep.step(TTR("Sending archive for notarization"), 4)) {
2314
return ERR_SKIP;
2315
}
2316
err = _notarize(p_preset, noto_path);
2317
}
2318
}
2319
2320
if (FileAccess::exists(ent_path)) {
2321
print_verbose("entitlements:\n" + FileAccess::get_file_as_string(ent_path));
2322
}
2323
2324
if (FileAccess::exists(hlp_ent_path)) {
2325
print_verbose("helper entitlements:\n" + FileAccess::get_file_as_string(hlp_ent_path));
2326
}
2327
2328
// Clean up temporary entitlements files.
2329
if (FileAccess::exists(hlp_ent_path)) {
2330
DirAccess::remove_file_or_error(hlp_ent_path);
2331
}
2332
2333
// Clean up temporary .app dir and generated entitlements.
2334
if ((String)(p_preset->get("codesign/entitlements/custom_file")) == "") {
2335
tmp_app_dir->remove(ent_path);
2336
}
2337
if (export_format != "app") {
2338
if (tmp_app_dir->change_dir(tmp_base_path_name) == OK) {
2339
tmp_app_dir->erase_contents_recursive();
2340
tmp_app_dir->change_dir("..");
2341
tmp_app_dir->remove(pkg_name);
2342
}
2343
} else if (noto_path != p_path) {
2344
if (FileAccess::exists(noto_path)) {
2345
DirAccess::remove_file_or_error(noto_path);
2346
}
2347
}
2348
}
2349
2350
return err;
2351
}
2352
2353
bool EditorExportPlatformMacOS::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
2354
String err;
2355
// Look for export templates (official templates first, then custom).
2356
bool dvalid = exists_export_template("macos.zip", &err);
2357
bool rvalid = dvalid; // Both in the same ZIP.
2358
2359
if (p_preset->get("custom_template/debug") != "") {
2360
dvalid = FileAccess::exists(p_preset->get("custom_template/debug"));
2361
if (!dvalid) {
2362
err += TTR("Custom debug template not found.") + "\n";
2363
}
2364
}
2365
if (p_preset->get("custom_template/release") != "") {
2366
rvalid = FileAccess::exists(p_preset->get("custom_template/release"));
2367
if (!rvalid) {
2368
err += TTR("Custom release template not found.") + "\n";
2369
}
2370
}
2371
2372
bool valid = dvalid || rvalid;
2373
r_missing_templates = !valid;
2374
2375
// Check the texture formats, which vary depending on the target architecture.
2376
String architecture = p_preset->get("binary_format/architecture");
2377
if (architecture == "universal" || architecture == "x86_64") {
2378
if (!ResourceImporterTextureSettings::should_import_s3tc_bptc()) {
2379
err += TTR("Cannot export for universal or x86_64 if S3TC BPTC texture format is disabled. Enable it in the Project Settings (Rendering > Textures > VRAM Compression > Import S3TC BPTC).") + "\n";
2380
valid = false;
2381
}
2382
}
2383
if (architecture == "universal" || architecture == "arm64") {
2384
if (!ResourceImporterTextureSettings::should_import_etc2_astc()) {
2385
err += TTR("Cannot export for universal or arm64 if ETC2 ASTC texture format is disabled. Enable it in the Project Settings (Rendering > Textures > VRAM Compression > Import ETC2 ASTC).") + "\n";
2386
valid = false;
2387
}
2388
}
2389
if (architecture != "universal" && architecture != "x86_64" && architecture != "arm64") {
2390
ERR_PRINT("Invalid architecture");
2391
}
2392
2393
if (!err.is_empty()) {
2394
r_error = err;
2395
}
2396
return valid;
2397
}
2398
2399
bool EditorExportPlatformMacOS::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
2400
String err;
2401
bool valid = true;
2402
2403
int dist_type = p_preset->get("export/distribution_type");
2404
bool ad_hoc = false;
2405
int codesign_tool = p_preset->get("codesign/codesign");
2406
int notary_tool = p_preset->get("notarization/notarization");
2407
switch (codesign_tool) {
2408
case 1: { // built-in ad-hoc
2409
ad_hoc = true;
2410
} break;
2411
case 2: { // "rcodesign"
2412
ad_hoc = p_preset->get_or_env("codesign/certificate_file", ENV_MAC_CODESIGN_CERT_FILE).operator String().is_empty() || p_preset->get_or_env("codesign/certificate_password", ENV_MAC_CODESIGN_CERT_PASS).operator String().is_empty();
2413
} break;
2414
#ifdef MACOS_ENABLED
2415
case 3: { // "codesign"
2416
ad_hoc = (p_preset->get("codesign/identity") == "" || p_preset->get("codesign/identity") == "-");
2417
} break;
2418
#endif
2419
default: {
2420
};
2421
}
2422
2423
const String &additional_plist_content = p_preset->get("application/additional_plist_content");
2424
if (!additional_plist_content.is_empty()) {
2425
const String &plist = vformat("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
2426
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"
2427
"<plist version=\"1.0\">"
2428
"<dict>\n"
2429
"%s\n"
2430
"</dict>\n"
2431
"</plist>\n",
2432
additional_plist_content);
2433
2434
String plist_err;
2435
Ref<PList> plist_parser;
2436
plist_parser.instantiate();
2437
if (!plist_parser->load_string(plist, plist_err)) {
2438
err += TTR("Invalid additional PList content: ") + plist_err + "\n";
2439
valid = false;
2440
}
2441
}
2442
2443
List<ExportOption> options;
2444
get_export_options(&options);
2445
for (const EditorExportPlatform::ExportOption &E : options) {
2446
if (get_export_option_visibility(p_preset.ptr(), E.option.name)) {
2447
String warn = get_export_option_warning(p_preset.ptr(), E.option.name);
2448
if (!warn.is_empty()) {
2449
err += warn + "\n";
2450
if (E.required) {
2451
valid = false;
2452
}
2453
}
2454
}
2455
}
2456
2457
if (dist_type != 2) {
2458
if (notary_tool > 0) {
2459
if (notary_tool == 2 || notary_tool == 3) {
2460
if (!FileAccess::exists("/usr/bin/xcrun") && !FileAccess::exists("/bin/xcrun")) {
2461
err += TTR("Notarization: Xcode command line tools are not installed.") + "\n";
2462
valid = false;
2463
}
2464
} else if (notary_tool == 1) {
2465
String rcodesign = EDITOR_GET("export/macos/rcodesign").operator String();
2466
if (rcodesign.is_empty()) {
2467
err += TTR("Notarization: rcodesign path is not set. Configure rcodesign path in the Editor Settings (Export > macOS > rcodesign).") + "\n";
2468
valid = false;
2469
}
2470
}
2471
} else {
2472
err += TTR("Warning: Notarization is disabled. The exported project will be blocked by Gatekeeper if it's downloaded from an unknown source.") + "\n";
2473
if (codesign_tool == 0) {
2474
err += TTR("Code signing is disabled. The exported project will not run on Macs with enabled Gatekeeper and Apple Silicon powered Macs.") + "\n";
2475
}
2476
}
2477
}
2478
2479
if (codesign_tool > 0) {
2480
if (ad_hoc) {
2481
err += TTR("Code signing: Using ad-hoc signature. The exported project will be blocked by Gatekeeper") + "\n";
2482
}
2483
if (codesign_tool == 3) {
2484
if (!FileAccess::exists("/usr/bin/codesign") && !FileAccess::exists("/bin/codesign")) {
2485
err += TTR("Code signing: Xcode command line tools are not installed.") + "\n";
2486
valid = false;
2487
}
2488
} else if (codesign_tool == 2) {
2489
String rcodesign = EDITOR_GET("export/macos/rcodesign").operator String();
2490
if (rcodesign.is_empty()) {
2491
err += TTR("Code signing: rcodesign path is not set. Configure rcodesign path in the Editor Settings (Export > macOS > rcodesign).") + "\n";
2492
valid = false;
2493
}
2494
}
2495
}
2496
2497
if (!err.is_empty()) {
2498
r_error = err;
2499
}
2500
return valid;
2501
}
2502
2503
Ref<Texture2D> EditorExportPlatformMacOS::get_run_icon() const {
2504
return run_icon;
2505
}
2506
2507
bool EditorExportPlatformMacOS::poll_export() {
2508
Ref<EditorExportPreset> preset;
2509
2510
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
2511
Ref<EditorExportPreset> ep = EditorExport::get_singleton()->get_export_preset(i);
2512
if (ep->is_runnable() && ep->get_platform() == this) {
2513
preset = ep;
2514
break;
2515
}
2516
}
2517
2518
int prev = menu_options;
2519
menu_options = (preset.is_valid() && preset->get("ssh_remote_deploy/enabled").operator bool());
2520
if (ssh_pid != 0 || !cleanup_commands.is_empty()) {
2521
if (menu_options == 0) {
2522
cleanup();
2523
} else {
2524
menu_options += 1;
2525
}
2526
}
2527
return menu_options != prev;
2528
}
2529
2530
Ref<Texture2D> EditorExportPlatformMacOS::get_option_icon(int p_index) const {
2531
if (p_index == 1) {
2532
return stop_icon;
2533
} else {
2534
return EditorExportPlatform::get_option_icon(p_index);
2535
}
2536
}
2537
2538
int EditorExportPlatformMacOS::get_options_count() const {
2539
return menu_options;
2540
}
2541
2542
String EditorExportPlatformMacOS::get_option_label(int p_index) const {
2543
return (p_index) ? TTR("Stop and uninstall") : TTR("Run on remote macOS system");
2544
}
2545
2546
String EditorExportPlatformMacOS::get_option_tooltip(int p_index) const {
2547
return (p_index) ? TTR("Stop and uninstall running project from the remote system") : TTR("Run exported project on remote macOS system");
2548
}
2549
2550
void EditorExportPlatformMacOS::cleanup() {
2551
if (ssh_pid != 0 && OS::get_singleton()->is_process_running(ssh_pid)) {
2552
print_line("Terminating connection...");
2553
OS::get_singleton()->kill(ssh_pid);
2554
OS::get_singleton()->delay_usec(1000);
2555
}
2556
2557
if (!cleanup_commands.is_empty()) {
2558
print_line("Stopping and deleting previous version...");
2559
for (const SSHCleanupCommand &cmd : cleanup_commands) {
2560
if (cmd.wait) {
2561
ssh_run_on_remote(cmd.host, cmd.port, cmd.ssh_args, cmd.cmd_args);
2562
} else {
2563
ssh_run_on_remote_no_wait(cmd.host, cmd.port, cmd.ssh_args, cmd.cmd_args);
2564
}
2565
}
2566
}
2567
ssh_pid = 0;
2568
cleanup_commands.clear();
2569
}
2570
2571
Error EditorExportPlatformMacOS::run(const Ref<EditorExportPreset> &p_preset, int p_device, BitField<EditorExportPlatform::DebugFlags> p_debug_flags) {
2572
cleanup();
2573
if (p_device) { // Stop command, cleanup only.
2574
return OK;
2575
}
2576
2577
EditorProgress ep("run", TTR("Running..."), 5);
2578
2579
const String dest = EditorPaths::get_singleton()->get_temp_dir().path_join("macos");
2580
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
2581
if (!da->dir_exists(dest)) {
2582
Error err = da->make_dir_recursive(dest);
2583
if (err != OK) {
2584
EditorNode::get_singleton()->show_warning(TTR("Could not create temp directory:") + "\n" + dest);
2585
return err;
2586
}
2587
}
2588
2589
String pkg_name;
2590
if (String(get_project_setting(p_preset, "application/config/name")) != "") {
2591
pkg_name = String(get_project_setting(p_preset, "application/config/name"));
2592
} else {
2593
pkg_name = "Unnamed";
2594
}
2595
pkg_name = OS::get_singleton()->get_safe_dir_name(pkg_name);
2596
2597
String host = p_preset->get("ssh_remote_deploy/host").operator String();
2598
String port = p_preset->get("ssh_remote_deploy/port").operator String();
2599
if (port.is_empty()) {
2600
port = "22";
2601
}
2602
Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" ", false);
2603
Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" ", false);
2604
2605
const String basepath = dest.path_join("tmp_macos_export");
2606
2607
#define CLEANUP_AND_RETURN(m_err) \
2608
{ \
2609
if (da->file_exists(basepath + ".zip")) { \
2610
da->remove(basepath + ".zip"); \
2611
} \
2612
if (da->file_exists(basepath + "_start.sh")) { \
2613
da->remove(basepath + "_start.sh"); \
2614
} \
2615
if (da->file_exists(basepath + "_clean.sh")) { \
2616
da->remove(basepath + "_clean.sh"); \
2617
} \
2618
return m_err; \
2619
} \
2620
((void)0)
2621
2622
if (ep.step(TTR("Exporting project..."), 1)) {
2623
return ERR_SKIP;
2624
}
2625
Error err = export_project(p_preset, true, basepath + ".zip", p_debug_flags);
2626
if (err != OK) {
2627
DirAccess::remove_file_or_error(basepath + ".zip");
2628
return err;
2629
}
2630
2631
String cmd_args;
2632
{
2633
Vector<String> cmd_args_list = gen_export_flags(p_debug_flags);
2634
for (int i = 0; i < cmd_args_list.size(); i++) {
2635
if (i != 0) {
2636
cmd_args += " ";
2637
}
2638
cmd_args += cmd_args_list[i];
2639
}
2640
}
2641
2642
const bool use_remote = p_debug_flags.has_flag(DEBUG_FLAG_REMOTE_DEBUG) || p_debug_flags.has_flag(DEBUG_FLAG_DUMB_CLIENT);
2643
int dbg_port = EDITOR_GET("network/debug/remote_port");
2644
2645
print_line("Creating temporary directory...");
2646
ep.step(TTR("Creating temporary directory..."), 2);
2647
String temp_dir;
2648
err = ssh_run_on_remote(host, port, extra_args_ssh, "mktemp -d", &temp_dir);
2649
if (err != OK || temp_dir.is_empty()) {
2650
CLEANUP_AND_RETURN(err);
2651
}
2652
2653
print_line("Uploading archive...");
2654
ep.step(TTR("Uploading archive..."), 3);
2655
err = ssh_push_to_remote(host, port, extra_args_scp, basepath + ".zip", temp_dir);
2656
if (err != OK) {
2657
CLEANUP_AND_RETURN(err);
2658
}
2659
2660
{
2661
String run_script = p_preset->get("ssh_remote_deploy/run_script");
2662
run_script = run_script.replace("{temp_dir}", temp_dir);
2663
run_script = run_script.replace("{archive_name}", basepath.get_file() + ".zip");
2664
run_script = run_script.replace("{exe_name}", pkg_name);
2665
run_script = run_script.replace("{cmd_args}", cmd_args);
2666
2667
Ref<FileAccess> f = FileAccess::open(basepath + "_start.sh", FileAccess::WRITE);
2668
if (f.is_null()) {
2669
CLEANUP_AND_RETURN(err);
2670
}
2671
2672
f->store_string(run_script);
2673
}
2674
2675
{
2676
String clean_script = p_preset->get("ssh_remote_deploy/cleanup_script");
2677
clean_script = clean_script.replace("{temp_dir}", temp_dir);
2678
clean_script = clean_script.replace("{archive_name}", basepath.get_file() + ".zip");
2679
clean_script = clean_script.replace("{exe_name}", pkg_name);
2680
clean_script = clean_script.replace("{cmd_args}", cmd_args);
2681
2682
Ref<FileAccess> f = FileAccess::open(basepath + "_clean.sh", FileAccess::WRITE);
2683
if (f.is_null()) {
2684
CLEANUP_AND_RETURN(err);
2685
}
2686
2687
f->store_string(clean_script);
2688
}
2689
2690
print_line("Uploading scripts...");
2691
ep.step(TTR("Uploading scripts..."), 4);
2692
err = ssh_push_to_remote(host, port, extra_args_scp, basepath + "_start.sh", temp_dir);
2693
if (err != OK) {
2694
CLEANUP_AND_RETURN(err);
2695
}
2696
err = ssh_run_on_remote(host, port, extra_args_ssh, vformat("chmod +x \"%s/%s\"", temp_dir, basepath.get_file() + "_start.sh"));
2697
if (err != OK || temp_dir.is_empty()) {
2698
CLEANUP_AND_RETURN(err);
2699
}
2700
err = ssh_push_to_remote(host, port, extra_args_scp, basepath + "_clean.sh", temp_dir);
2701
if (err != OK) {
2702
CLEANUP_AND_RETURN(err);
2703
}
2704
err = ssh_run_on_remote(host, port, extra_args_ssh, vformat("chmod +x \"%s/%s\"", temp_dir, basepath.get_file() + "_clean.sh"));
2705
if (err != OK || temp_dir.is_empty()) {
2706
CLEANUP_AND_RETURN(err);
2707
}
2708
2709
print_line("Starting project...");
2710
ep.step(TTR("Starting project..."), 5);
2711
err = ssh_run_on_remote_no_wait(host, port, extra_args_ssh, vformat("\"%s/%s\"", temp_dir, basepath.get_file() + "_start.sh"), &ssh_pid, (use_remote) ? dbg_port : -1);
2712
if (err != OK) {
2713
CLEANUP_AND_RETURN(err);
2714
}
2715
2716
cleanup_commands.clear();
2717
cleanup_commands.push_back(SSHCleanupCommand(host, port, extra_args_ssh, vformat("\"%s/%s\"", temp_dir, basepath.get_file() + "_clean.sh")));
2718
2719
print_line("Project started.");
2720
2721
CLEANUP_AND_RETURN(OK);
2722
#undef CLEANUP_AND_RETURN
2723
}
2724
2725
EditorExportPlatformMacOS::EditorExportPlatformMacOS() {
2726
if (EditorNode::get_singleton()) {
2727
Ref<Image> img = memnew(Image);
2728
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
2729
2730
ImageLoaderSVG::create_image_from_string(img, _macos_logo_svg, EDSCALE, upsample, false);
2731
logo = ImageTexture::create_from_image(img);
2732
2733
ImageLoaderSVG::create_image_from_string(img, _macos_run_icon_svg, EDSCALE, upsample, false);
2734
run_icon = ImageTexture::create_from_image(img);
2735
2736
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
2737
if (theme.is_valid()) {
2738
stop_icon = theme->get_icon(SNAME("Stop"), EditorStringName(EditorIcons));
2739
} else {
2740
stop_icon.instantiate();
2741
}
2742
}
2743
}
2744
2745