export_plugin.cpp 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697
  1. /*************************************************************************/
  2. /* export_plugin.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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. #include "export_plugin.h"
  31. #include "codesign.h"
  32. #include "core/string/translation.h"
  33. #include "editor/editor_node.h"
  34. #include "editor/editor_paths.h"
  35. #include "modules/modules_enabled.gen.h" // For regex.
  36. void EditorExportPlatformMacOS::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const {
  37. if (p_preset->get("texture_format/s3tc")) {
  38. r_features->push_back("s3tc");
  39. }
  40. if (p_preset->get("texture_format/etc")) {
  41. r_features->push_back("etc");
  42. }
  43. if (p_preset->get("texture_format/etc2")) {
  44. r_features->push_back("etc2");
  45. }
  46. r_features->push_back(p_preset->get("binary_format/architecture"));
  47. }
  48. bool EditorExportPlatformMacOS::get_export_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const {
  49. // These options are not supported by built-in codesign, used on non macOS host.
  50. if (!OS::get_singleton()->has_feature("macos")) {
  51. if (p_option == "codesign/identity" || p_option == "codesign/timestamp" || p_option == "codesign/hardened_runtime" || p_option == "codesign/custom_options" || p_option.begins_with("notarization/")) {
  52. return false;
  53. }
  54. }
  55. // These entitlements are required to run managed code, and are always enabled in Mono builds.
  56. if (Engine::get_singleton()->has_singleton("GodotSharp")) {
  57. 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") {
  58. return false;
  59. }
  60. }
  61. return true;
  62. }
  63. void EditorExportPlatformMacOS::get_export_options(List<ExportOption> *r_options) {
  64. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "binary_format/architecture", PROPERTY_HINT_ENUM, "universal,x86_64,arm64", PROPERTY_USAGE_STORAGE), "universal"));
  65. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
  66. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
  67. r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_script", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1));
  68. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.png,*.icns"), ""));
  69. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/bundle_identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), ""));
  70. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), ""));
  71. 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"));
  72. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version"), "1.0"));
  73. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version"), "1.0"));
  74. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));
  75. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "application/copyright_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  76. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "display/high_res"), false));
  77. 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"), ""));
  78. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/microphone_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  79. 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"), ""));
  80. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/camera_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  81. 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"), ""));
  82. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/location_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  83. 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"), ""));
  84. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/address_book_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  85. 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"), ""));
  86. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/calendar_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  87. 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"), ""));
  88. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/photos_library_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  89. 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"), ""));
  90. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/desktop_folder_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  91. 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"), ""));
  92. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/documents_folder_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  93. 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"), ""));
  94. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/downloads_folder_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  95. 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"), ""));
  96. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/network_volumes_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  97. 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"), ""));
  98. r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "privacy/removable_volumes_usage_description_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()));
  99. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/enable"), true));
  100. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/identity", PROPERTY_HINT_PLACEHOLDER_TEXT, "Type: Name (ID)"), ""));
  101. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/timestamp"), true));
  102. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/replace_existing_signature"), true));
  103. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/hardened_runtime"), true));
  104. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/entitlements/custom_file", PROPERTY_HINT_GLOBAL_FILE, "*.plist"), ""));
  105. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_jit_code_execution"), false));
  106. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_unsigned_executable_memory"), false));
  107. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_dyld_environment_variables"), false));
  108. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/disable_library_validation"), false));
  109. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/audio_input"), false));
  110. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/camera"), false));
  111. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/location"), false));
  112. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/address_book"), false));
  113. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/calendars"), false));
  114. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/photos_library"), false));
  115. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/apple_events"), false));
  116. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/debugging"), false));
  117. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/enabled"), false));
  118. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/network_server"), false));
  119. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/network_client"), false));
  120. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/device_usb"), false));
  121. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/device_bluetooth"), false));
  122. r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_downloads", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
  123. r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_pictures", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
  124. r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_music", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
  125. r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_movies", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
  126. 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()));
  127. r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "codesign/custom_options"), PackedStringArray()));
  128. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "notarization/enable"), false));
  129. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_id_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Apple ID email"), ""));
  130. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_id_password", PROPERTY_HINT_PLACEHOLDER_TEXT, "Enable two-factor authentication and provide app-specific password"), ""));
  131. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_team_id", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide team ID if your Apple ID belongs to multiple teams"), ""));
  132. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true));
  133. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
  134. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false));
  135. }
  136. void _rgba8_to_packbits_encode(int p_ch, int p_size, Vector<uint8_t> &p_source, Vector<uint8_t> &p_dest) {
  137. int src_len = p_size * p_size;
  138. Vector<uint8_t> result;
  139. result.resize(src_len * 1.25); //temp vector for rle encoded data, make it 25% larger for worst case scenario
  140. int res_size = 0;
  141. uint8_t buf[128];
  142. int buf_size = 0;
  143. int i = 0;
  144. while (i < src_len) {
  145. uint8_t cur = p_source.ptr()[i * 4 + p_ch];
  146. if (i < src_len - 2) {
  147. if ((p_source.ptr()[(i + 1) * 4 + p_ch] == cur) && (p_source.ptr()[(i + 2) * 4 + p_ch] == cur)) {
  148. if (buf_size > 0) {
  149. result.write[res_size++] = (uint8_t)(buf_size - 1);
  150. memcpy(&result.write[res_size], &buf, buf_size);
  151. res_size += buf_size;
  152. buf_size = 0;
  153. }
  154. uint8_t lim = i + 130 >= src_len ? src_len - i - 1 : 130;
  155. bool hit_lim = true;
  156. for (int j = 3; j <= lim; j++) {
  157. if (p_source.ptr()[(i + j) * 4 + p_ch] != cur) {
  158. hit_lim = false;
  159. i = i + j - 1;
  160. result.write[res_size++] = (uint8_t)(j - 3 + 0x80);
  161. result.write[res_size++] = cur;
  162. break;
  163. }
  164. }
  165. if (hit_lim) {
  166. result.write[res_size++] = (uint8_t)(lim - 3 + 0x80);
  167. result.write[res_size++] = cur;
  168. i = i + lim;
  169. }
  170. } else {
  171. buf[buf_size++] = cur;
  172. if (buf_size == 128) {
  173. result.write[res_size++] = (uint8_t)(buf_size - 1);
  174. memcpy(&result.write[res_size], &buf, buf_size);
  175. res_size += buf_size;
  176. buf_size = 0;
  177. }
  178. }
  179. } else {
  180. buf[buf_size++] = cur;
  181. result.write[res_size++] = (uint8_t)(buf_size - 1);
  182. memcpy(&result.write[res_size], &buf, buf_size);
  183. res_size += buf_size;
  184. buf_size = 0;
  185. }
  186. i++;
  187. }
  188. int ofs = p_dest.size();
  189. p_dest.resize(p_dest.size() + res_size);
  190. memcpy(&p_dest.write[ofs], result.ptr(), res_size);
  191. }
  192. void EditorExportPlatformMacOS::_make_icon(const Ref<Image> &p_icon, Vector<uint8_t> &p_data) {
  193. Ref<ImageTexture> it = memnew(ImageTexture);
  194. Vector<uint8_t> data;
  195. data.resize(8);
  196. data.write[0] = 'i';
  197. data.write[1] = 'c';
  198. data.write[2] = 'n';
  199. data.write[3] = 's';
  200. struct MacOSIconInfo {
  201. const char *name;
  202. const char *mask_name;
  203. bool is_png;
  204. int size;
  205. };
  206. static const MacOSIconInfo icon_infos[] = {
  207. { "ic10", "", true, 1024 }, //1024×1024 32-bit PNG and 512×512@2x 32-bit "retina" PNG
  208. { "ic09", "", true, 512 }, //512×512 32-bit PNG
  209. { "ic14", "", true, 512 }, //256×256@2x 32-bit "retina" PNG
  210. { "ic08", "", true, 256 }, //256×256 32-bit PNG
  211. { "ic13", "", true, 256 }, //128×128@2x 32-bit "retina" PNG
  212. { "ic07", "", true, 128 }, //128×128 32-bit PNG
  213. { "ic12", "", true, 64 }, //32×32@2× 32-bit "retina" PNG
  214. { "ic11", "", true, 32 }, //16×16@2× 32-bit "retina" PNG
  215. { "il32", "l8mk", false, 32 }, //32×32 24-bit RLE + 8-bit uncompressed mask
  216. { "is32", "s8mk", false, 16 } //16×16 24-bit RLE + 8-bit uncompressed mask
  217. };
  218. for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
  219. Ref<Image> copy = p_icon; // does this make sense? doesn't this just increase the reference count instead of making a copy? Do we even need a copy?
  220. copy->convert(Image::FORMAT_RGBA8);
  221. copy->resize(icon_infos[i].size, icon_infos[i].size);
  222. if (icon_infos[i].is_png) {
  223. // Encode PNG icon.
  224. it->set_image(copy);
  225. String path = EditorPaths::get_singleton()->get_cache_dir().plus_file("icon.png");
  226. ResourceSaver::save(it, path);
  227. {
  228. Ref<FileAccess> f = FileAccess::open(path, FileAccess::READ);
  229. if (f.is_null()) {
  230. // Clean up generated file.
  231. DirAccess::remove_file_or_error(path);
  232. add_message(EXPORT_MESSAGE_ERROR, TTR("Icon Creation"), vformat(TTR("Could not open icon file \"%s\"."), path));
  233. return;
  234. }
  235. int ofs = data.size();
  236. uint64_t len = f->get_length();
  237. data.resize(data.size() + len + 8);
  238. f->get_buffer(&data.write[ofs + 8], len);
  239. len += 8;
  240. len = BSWAP32(len);
  241. memcpy(&data.write[ofs], icon_infos[i].name, 4);
  242. encode_uint32(len, &data.write[ofs + 4]);
  243. }
  244. // Clean up generated file.
  245. DirAccess::remove_file_or_error(path);
  246. } else {
  247. Vector<uint8_t> src_data = copy->get_data();
  248. //encode 24bit RGB RLE icon
  249. {
  250. int ofs = data.size();
  251. data.resize(data.size() + 8);
  252. _rgba8_to_packbits_encode(0, icon_infos[i].size, src_data, data); // encode R
  253. _rgba8_to_packbits_encode(1, icon_infos[i].size, src_data, data); // encode G
  254. _rgba8_to_packbits_encode(2, icon_infos[i].size, src_data, data); // encode B
  255. int len = data.size() - ofs;
  256. len = BSWAP32(len);
  257. memcpy(&data.write[ofs], icon_infos[i].name, 4);
  258. encode_uint32(len, &data.write[ofs + 4]);
  259. }
  260. //encode 8bit mask uncompressed icon
  261. {
  262. int ofs = data.size();
  263. int len = copy->get_width() * copy->get_height();
  264. data.resize(data.size() + len + 8);
  265. for (int j = 0; j < len; j++) {
  266. data.write[ofs + 8 + j] = src_data.ptr()[j * 4 + 3];
  267. }
  268. len += 8;
  269. len = BSWAP32(len);
  270. memcpy(&data.write[ofs], icon_infos[i].mask_name, 4);
  271. encode_uint32(len, &data.write[ofs + 4]);
  272. }
  273. }
  274. }
  275. uint32_t total_len = data.size();
  276. total_len = BSWAP32(total_len);
  277. encode_uint32(total_len, &data.write[4]);
  278. p_data = data;
  279. }
  280. void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary) {
  281. String str;
  282. String strnew;
  283. str.parse_utf8((const char *)plist.ptr(), plist.size());
  284. Vector<String> lines = str.split("\n");
  285. for (int i = 0; i < lines.size(); i++) {
  286. if (lines[i].find("$binary") != -1) {
  287. strnew += lines[i].replace("$binary", p_binary) + "\n";
  288. } else if (lines[i].find("$name") != -1) {
  289. strnew += lines[i].replace("$name", ProjectSettings::get_singleton()->get("application/config/name")) + "\n";
  290. } else if (lines[i].find("$bundle_identifier") != -1) {
  291. strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n";
  292. } else if (lines[i].find("$short_version") != -1) {
  293. strnew += lines[i].replace("$short_version", p_preset->get("application/short_version")) + "\n";
  294. } else if (lines[i].find("$version") != -1) {
  295. strnew += lines[i].replace("$version", p_preset->get("application/version")) + "\n";
  296. } else if (lines[i].find("$signature") != -1) {
  297. strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n";
  298. } else if (lines[i].find("$app_category") != -1) {
  299. String cat = p_preset->get("application/app_category");
  300. strnew += lines[i].replace("$app_category", cat.to_lower()) + "\n";
  301. } else if (lines[i].find("$copyright") != -1) {
  302. strnew += lines[i].replace("$copyright", p_preset->get("application/copyright")) + "\n";
  303. } else if (lines[i].find("$highres") != -1) {
  304. strnew += lines[i].replace("$highres", p_preset->get("display/high_res") ? "\t<true/>" : "\t<false/>") + "\n";
  305. } else if (lines[i].find("$usage_descriptions") != -1) {
  306. String descriptions;
  307. if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) {
  308. descriptions += "\t<key>NSMicrophoneUsageDescription</key>\n";
  309. descriptions += "\t<string>" + (String)p_preset->get("privacy/microphone_usage_description") + "</string>\n";
  310. }
  311. if (!((String)p_preset->get("privacy/camera_usage_description")).is_empty()) {
  312. descriptions += "\t<key>NSCameraUsageDescription</key>\n";
  313. descriptions += "\t<string>" + (String)p_preset->get("privacy/camera_usage_description") + "</string>\n";
  314. }
  315. if (!((String)p_preset->get("privacy/location_usage_description")).is_empty()) {
  316. descriptions += "\t<key>NSLocationUsageDescription</key>\n";
  317. descriptions += "\t<string>" + (String)p_preset->get("privacy/location_usage_description") + "</string>\n";
  318. }
  319. if (!((String)p_preset->get("privacy/address_book_usage_description")).is_empty()) {
  320. descriptions += "\t<key>NSContactsUsageDescription</key>\n";
  321. descriptions += "\t<string>" + (String)p_preset->get("privacy/address_book_usage_description") + "</string>\n";
  322. }
  323. if (!((String)p_preset->get("privacy/calendar_usage_description")).is_empty()) {
  324. descriptions += "\t<key>NSCalendarsUsageDescription</key>\n";
  325. descriptions += "\t<string>" + (String)p_preset->get("privacy/calendar_usage_description") + "</string>\n";
  326. }
  327. if (!((String)p_preset->get("privacy/photos_library_usage_description")).is_empty()) {
  328. descriptions += "\t<key>NSPhotoLibraryUsageDescription</key>\n";
  329. descriptions += "\t<string>" + (String)p_preset->get("privacy/photos_library_usage_description") + "</string>\n";
  330. }
  331. if (!((String)p_preset->get("privacy/desktop_folder_usage_description")).is_empty()) {
  332. descriptions += "\t<key>NSDesktopFolderUsageDescription</key>\n";
  333. descriptions += "\t<string>" + (String)p_preset->get("privacy/desktop_folder_usage_description") + "</string>\n";
  334. }
  335. if (!((String)p_preset->get("privacy/documents_folder_usage_description")).is_empty()) {
  336. descriptions += "\t<key>NSDocumentsFolderUsageDescription</key>\n";
  337. descriptions += "\t<string>" + (String)p_preset->get("privacy/documents_folder_usage_description") + "</string>\n";
  338. }
  339. if (!((String)p_preset->get("privacy/downloads_folder_usage_description")).is_empty()) {
  340. descriptions += "\t<key>NSDownloadsFolderUsageDescription</key>\n";
  341. descriptions += "\t<string>" + (String)p_preset->get("privacy/downloads_folder_usage_description") + "</string>\n";
  342. }
  343. if (!((String)p_preset->get("privacy/network_volumes_usage_description")).is_empty()) {
  344. descriptions += "\t<key>NSNetworkVolumesUsageDescription</key>\n";
  345. descriptions += "\t<string>" + (String)p_preset->get("privacy/network_volumes_usage_description") + "</string>\n";
  346. }
  347. if (!((String)p_preset->get("privacy/removable_volumes_usage_description")).is_empty()) {
  348. descriptions += "\t<key>NSRemovableVolumesUsageDescription</key>\n";
  349. descriptions += "\t<string>" + (String)p_preset->get("privacy/removable_volumes_usage_description") + "</string>\n";
  350. }
  351. if (!descriptions.is_empty()) {
  352. strnew += lines[i].replace("$usage_descriptions", descriptions);
  353. }
  354. } else {
  355. strnew += lines[i] + "\n";
  356. }
  357. }
  358. CharString cs = strnew.utf8();
  359. plist.resize(cs.size() - 1);
  360. for (int i = 0; i < cs.size() - 1; i++) {
  361. plist.write[i] = cs[i];
  362. }
  363. }
  364. /**
  365. * If we're running the macOS version of the Godot editor we'll:
  366. * - export our application bundle to a temporary folder
  367. * - attempt to code sign it
  368. * - and then wrap it up in a DMG
  369. */
  370. Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
  371. #ifdef MACOS_ENABLED
  372. List<String> args;
  373. args.push_back("altool");
  374. args.push_back("--notarize-app");
  375. args.push_back("--primary-bundle-id");
  376. args.push_back(p_preset->get("application/bundle_identifier"));
  377. args.push_back("--username");
  378. args.push_back(p_preset->get("notarization/apple_id_name"));
  379. args.push_back("--password");
  380. args.push_back(p_preset->get("notarization/apple_id_password"));
  381. args.push_back("--type");
  382. args.push_back("osx");
  383. if (p_preset->get("notarization/apple_team_id")) {
  384. args.push_back("--asc-provider");
  385. args.push_back(p_preset->get("notarization/apple_team_id"));
  386. }
  387. args.push_back("--file");
  388. args.push_back(p_path);
  389. String str;
  390. Error err = OS::get_singleton()->execute("xcrun", args, &str, nullptr, true);
  391. if (err != OK || (str.find("not found") != -1) || (str.find("not recognized") != -1)) {
  392. add_message(EXPORT_MESSAGE_WARNING, TTR("Notarization"), TTR("Could not start xcrun executable."));
  393. return err;
  394. }
  395. print_verbose("altool (" + p_path + "):\n" + str);
  396. int rq_offset = str.find("RequestUUID");
  397. if (rq_offset == -1) {
  398. add_message(EXPORT_MESSAGE_WARNING, TTR("Notarization"), TTR("Notarization failed."));
  399. return FAILED;
  400. } else {
  401. int next_nl = str.find("\n", rq_offset);
  402. String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 14, -1) : str.substr(rq_offset + 14, next_nl - rq_offset - 14);
  403. add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid));
  404. add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour. When the process is completed, you'll receive an email."));
  405. add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("You can check progress manually by opening a Terminal and running the following command:"));
  406. add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t\t\"xcrun altool --notarization-history 0 -u <your email> -p <app-specific pwd>\"");
  407. add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t" + TTR("Run the following command to staple the notarization ticket to the exported application (optional):"));
  408. add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), "\t\t\"xcrun stapler staple <app path>\"");
  409. }
  410. #endif
  411. return OK;
  412. }
  413. Error EditorExportPlatformMacOS::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path, bool p_warn) {
  414. bool force_builtin_codesign = EditorSettings::get_singleton()->get("export/macos/force_builtin_codesign");
  415. bool ad_hoc = (p_preset->get("codesign/identity") == "" || p_preset->get("codesign/identity") == "-");
  416. if ((!FileAccess::exists("/usr/bin/codesign") && !FileAccess::exists("/bin/codesign")) || force_builtin_codesign) {
  417. print_verbose("using built-in codesign...");
  418. #ifdef MODULE_REGEX_ENABLED
  419. #ifdef MACOS_ENABLED
  420. if (p_preset->get("codesign/timestamp") && p_warn) {
  421. add_message(EXPORT_MESSAGE_INFO, TTR("Code Signing"), TTR("Timestamping is not compatible with ad-hoc signature, and was disabled!"));
  422. }
  423. if (p_preset->get("codesign/hardened_runtime") && p_warn) {
  424. add_message(EXPORT_MESSAGE_INFO, TTR("Code Signing"), TTR("Hardened Runtime is not compatible with ad-hoc signature, and was disabled!"));
  425. }
  426. #endif
  427. String error_msg;
  428. Error err = CodeSign::codesign(false, p_preset->get("codesign/replace_existing_signature"), p_path, p_ent_path, error_msg);
  429. if (err != OK) {
  430. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Built-in CodeSign failed with error \"%s\"."), error_msg));
  431. return FAILED;
  432. }
  433. #else
  434. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Built-in CodeSign require regex module."));
  435. #endif
  436. return OK;
  437. } else {
  438. print_verbose("using external codesign...");
  439. List<String> args;
  440. if (p_preset->get("codesign/timestamp")) {
  441. if (ad_hoc) {
  442. if (p_warn) {
  443. add_message(EXPORT_MESSAGE_INFO, TTR("Code Signing"), TTR("Timestamping is not compatible with ad-hoc signature, and was disabled!"));
  444. }
  445. } else {
  446. args.push_back("--timestamp");
  447. }
  448. }
  449. if (p_preset->get("codesign/hardened_runtime")) {
  450. if (ad_hoc) {
  451. if (p_warn) {
  452. add_message(EXPORT_MESSAGE_INFO, TTR("Code Signing"), TTR("Hardened Runtime is not compatible with ad-hoc signature, and was disabled!"));
  453. }
  454. } else {
  455. args.push_back("--options");
  456. args.push_back("runtime");
  457. }
  458. }
  459. if (p_path.get_extension() != "dmg") {
  460. args.push_back("--entitlements");
  461. args.push_back(p_ent_path);
  462. }
  463. PackedStringArray user_args = p_preset->get("codesign/custom_options");
  464. for (int i = 0; i < user_args.size(); i++) {
  465. String user_arg = user_args[i].strip_edges();
  466. if (!user_arg.is_empty()) {
  467. args.push_back(user_arg);
  468. }
  469. }
  470. args.push_back("-s");
  471. if (ad_hoc) {
  472. args.push_back("-");
  473. } else {
  474. args.push_back(p_preset->get("codesign/identity"));
  475. }
  476. args.push_back("-v"); /* provide some more feedback */
  477. if (p_preset->get("codesign/replace_existing_signature")) {
  478. args.push_back("-f");
  479. }
  480. args.push_back(p_path);
  481. String str;
  482. Error err = OS::get_singleton()->execute("codesign", args, &str, nullptr, true);
  483. if (err != OK || (str.find("not found") != -1) || (str.find("not recognized") != -1)) {
  484. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Could not start codesign executable, make sure Xcode command line tools are installed."));
  485. return err;
  486. }
  487. print_verbose("codesign (" + p_path + "):\n" + str);
  488. if (str.find("no identity found") != -1) {
  489. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("No identity found."));
  490. return FAILED;
  491. }
  492. if ((str.find("unrecognized blob type") != -1) || (str.find("cannot read entitlement data") != -1)) {
  493. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Invalid entitlements file."));
  494. return FAILED;
  495. }
  496. return OK;
  497. }
  498. }
  499. Error EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPreset> &p_preset, const String &p_path,
  500. const String &p_ent_path, bool p_should_error_on_non_code) {
  501. #ifdef MACOS_ENABLED
  502. static Vector<String> extensions_to_sign;
  503. if (extensions_to_sign.is_empty()) {
  504. extensions_to_sign.push_back("dylib");
  505. extensions_to_sign.push_back("framework");
  506. }
  507. Error dir_access_error;
  508. Ref<DirAccess> dir_access{ DirAccess::open(p_path, &dir_access_error) };
  509. if (dir_access_error != OK) {
  510. return dir_access_error;
  511. }
  512. dir_access->list_dir_begin();
  513. String current_file{ dir_access->get_next() };
  514. while (!current_file.is_empty()) {
  515. String current_file_path{ p_path.plus_file(current_file) };
  516. if (current_file == ".." || current_file == ".") {
  517. current_file = dir_access->get_next();
  518. continue;
  519. }
  520. if (extensions_to_sign.find(current_file.get_extension()) > -1) {
  521. Error code_sign_error{ _code_sign(p_preset, current_file_path, p_ent_path, false) };
  522. if (code_sign_error != OK) {
  523. return code_sign_error;
  524. }
  525. } else if (dir_access->current_is_dir()) {
  526. Error code_sign_error{ _code_sign_directory(p_preset, current_file_path, p_ent_path, p_should_error_on_non_code) };
  527. if (code_sign_error != OK) {
  528. return code_sign_error;
  529. }
  530. } else if (p_should_error_on_non_code) {
  531. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Cannot sign file %s."), current_file));
  532. return Error::FAILED;
  533. }
  534. current_file = dir_access->get_next();
  535. }
  536. #endif
  537. return OK;
  538. }
  539. Error EditorExportPlatformMacOS::_copy_and_sign_files(Ref<DirAccess> &dir_access, const String &p_src_path,
  540. const String &p_in_app_path, bool p_sign_enabled,
  541. const Ref<EditorExportPreset> &p_preset, const String &p_ent_path,
  542. bool p_should_error_on_non_code_sign) {
  543. Error err{ OK };
  544. if (dir_access->dir_exists(p_src_path)) {
  545. #ifndef UNIX_ENABLED
  546. add_message(EXPORT_MESSAGE_INFO, TTR("Export"), vformat(TTR("Relative symlinks are not supported, exported \"%s\" might be broken!"), p_src_path.get_file()));
  547. #endif
  548. print_verbose("export framework: " + p_src_path + " -> " + p_in_app_path);
  549. err = dir_access->make_dir_recursive(p_in_app_path);
  550. if (err == OK) {
  551. err = dir_access->copy_dir(p_src_path, p_in_app_path, -1, true);
  552. }
  553. } else {
  554. print_verbose("export dylib: " + p_src_path + " -> " + p_in_app_path);
  555. err = dir_access->copy(p_src_path, p_in_app_path);
  556. }
  557. if (err == OK && p_sign_enabled) {
  558. if (dir_access->dir_exists(p_src_path) && p_src_path.get_extension().is_empty()) {
  559. // If it is a directory, find and sign all dynamic libraries.
  560. err = _code_sign_directory(p_preset, p_in_app_path, p_ent_path, p_should_error_on_non_code_sign);
  561. } else {
  562. err = _code_sign(p_preset, p_in_app_path, p_ent_path, false);
  563. }
  564. }
  565. return err;
  566. }
  567. Error EditorExportPlatformMacOS::_export_macos_plugins_for(Ref<EditorExportPlugin> p_editor_export_plugin,
  568. const String &p_app_path_name, Ref<DirAccess> &dir_access,
  569. bool p_sign_enabled, const Ref<EditorExportPreset> &p_preset,
  570. const String &p_ent_path) {
  571. Error error{ OK };
  572. const Vector<String> &macos_plugins{ p_editor_export_plugin->get_macos_plugin_files() };
  573. for (int i = 0; i < macos_plugins.size(); ++i) {
  574. String src_path{ ProjectSettings::get_singleton()->globalize_path(macos_plugins[i]) };
  575. String path_in_app{ p_app_path_name + "/Contents/PlugIns/" + src_path.get_file() };
  576. error = _copy_and_sign_files(dir_access, src_path, path_in_app, p_sign_enabled, p_preset, p_ent_path, false);
  577. if (error != OK) {
  578. break;
  579. }
  580. }
  581. return error;
  582. }
  583. Error EditorExportPlatformMacOS::_create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name) {
  584. List<String> args;
  585. if (FileAccess::exists(p_dmg_path)) {
  586. OS::get_singleton()->move_to_trash(p_dmg_path);
  587. }
  588. args.push_back("create");
  589. args.push_back(p_dmg_path);
  590. args.push_back("-volname");
  591. args.push_back(p_pkg_name);
  592. args.push_back("-fs");
  593. args.push_back("HFS+");
  594. args.push_back("-srcfolder");
  595. args.push_back(p_app_path_name);
  596. String str;
  597. Error err = OS::get_singleton()->execute("hdiutil", args, &str, nullptr, true);
  598. if (err != OK) {
  599. add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("Could not start hdiutil executable."));
  600. return err;
  601. }
  602. print_verbose("hdiutil returned: " + str);
  603. if (str.find("create failed") != -1) {
  604. if (str.find("File exists") != -1) {
  605. add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("`hdiutil create` failed - file exists."));
  606. } else {
  607. add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("`hdiutil create` failed."));
  608. }
  609. return FAILED;
  610. }
  611. return OK;
  612. }
  613. Error EditorExportPlatformMacOS::_export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path) {
  614. Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE);
  615. if (f.is_null()) {
  616. add_message(EXPORT_MESSAGE_ERROR, TTR("Debug Script Export"), vformat(TTR("Could not open file \"%s\"."), p_path));
  617. return ERR_CANT_CREATE;
  618. }
  619. f->store_line("#!/bin/sh");
  620. f->store_line("echo -ne '\\033c\\033]0;" + p_app_name + "\\a'");
  621. f->store_line("");
  622. f->store_line("function app_realpath() {");
  623. f->store_line(" SOURCE=$1");
  624. f->store_line(" while [ -h \"$SOURCE\" ]; do");
  625. f->store_line(" DIR=$(dirname \"$SOURCE\")");
  626. f->store_line(" SOURCE=$(readlink \"$SOURCE\")");
  627. f->store_line(" [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE");
  628. f->store_line(" done");
  629. f->store_line(" echo \"$( cd -P \"$( dirname \"$SOURCE\" )\" >/dev/null 2>&1 && pwd )\"");
  630. f->store_line("}");
  631. f->store_line("");
  632. f->store_line("BASE_PATH=\"$(app_realpath \"${BASH_SOURCE[0]}\")\"");
  633. f->store_line("\"$BASE_PATH/" + p_pkg_name + "\" \"$@\"");
  634. f->store_line("");
  635. return OK;
  636. }
  637. Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
  638. ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
  639. String src_pkg_name;
  640. EditorProgress ep("export", "Exporting for macOS", 3, true);
  641. if (p_debug) {
  642. src_pkg_name = p_preset->get("custom_template/debug");
  643. } else {
  644. src_pkg_name = p_preset->get("custom_template/release");
  645. }
  646. if (src_pkg_name.is_empty()) {
  647. String err;
  648. src_pkg_name = find_export_template("macos.zip", &err);
  649. if (src_pkg_name.is_empty()) {
  650. add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), TTR("Export template not found."));
  651. return ERR_FILE_NOT_FOUND;
  652. }
  653. }
  654. if (!DirAccess::exists(p_path.get_base_dir())) {
  655. add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), TTR("The given export path doesn't exist."));
  656. return ERR_FILE_BAD_PATH;
  657. }
  658. Ref<FileAccess> io_fa;
  659. zlib_filefunc_def io = zipio_create_io(&io_fa);
  660. if (ep.step(TTR("Creating app bundle"), 0)) {
  661. return ERR_SKIP;
  662. }
  663. unzFile src_pkg_zip = unzOpen2(src_pkg_name.utf8().get_data(), &io);
  664. if (!src_pkg_zip) {
  665. add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Could not find template app to export: \"%s\"."), src_pkg_name));
  666. return ERR_FILE_NOT_FOUND;
  667. }
  668. int ret = unzGoToFirstFile(src_pkg_zip);
  669. String architecture = p_preset->get("binary_format/architecture");
  670. String binary_to_use = "godot_macos_" + String(p_debug ? "debug" : "release") + "." + architecture;
  671. String pkg_name;
  672. if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") {
  673. pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
  674. } else {
  675. pkg_name = "Unnamed";
  676. }
  677. pkg_name = OS::get_singleton()->get_safe_dir_name(pkg_name);
  678. String export_format;
  679. if (use_dmg() && p_path.ends_with("dmg")) {
  680. export_format = "dmg";
  681. } else if (p_path.ends_with("zip")) {
  682. export_format = "zip";
  683. } else if (p_path.ends_with("app")) {
  684. export_format = "app";
  685. } else {
  686. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Invalid export format."));
  687. return ERR_CANT_CREATE;
  688. }
  689. // Create our application bundle.
  690. String tmp_app_dir_name = pkg_name + ".app";
  691. String tmp_base_path_name;
  692. String tmp_app_path_name;
  693. String scr_path;
  694. if (export_format == "app") {
  695. tmp_base_path_name = p_path.get_base_dir();
  696. tmp_app_path_name = p_path;
  697. scr_path = p_path.get_basename() + ".command";
  698. } else {
  699. tmp_base_path_name = EditorPaths::get_singleton()->get_cache_dir().plus_file(pkg_name);
  700. tmp_app_path_name = tmp_base_path_name.plus_file(tmp_app_dir_name);
  701. scr_path = tmp_base_path_name.plus_file(pkg_name + ".command");
  702. }
  703. print_verbose("Exporting to " + tmp_app_path_name);
  704. Error err = OK;
  705. Ref<DirAccess> tmp_app_dir = DirAccess::create_for_path(tmp_base_path_name);
  706. if (tmp_app_dir.is_null()) {
  707. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory: \"%s\"."), tmp_base_path_name));
  708. err = ERR_CANT_CREATE;
  709. }
  710. DirAccess::remove_file_or_error(scr_path);
  711. if (DirAccess::exists(tmp_app_path_name)) {
  712. String old_dir = tmp_app_dir->get_current_dir();
  713. if (tmp_app_dir->change_dir(tmp_app_path_name) == OK) {
  714. tmp_app_dir->erase_contents_recursive();
  715. tmp_app_dir->change_dir(old_dir);
  716. }
  717. }
  718. Array helpers = p_preset->get("codesign/entitlements/app_sandbox/helper_executables");
  719. // Create our folder structure.
  720. if (err == OK) {
  721. print_verbose("Creating " + tmp_app_path_name + "/Contents/MacOS");
  722. err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/MacOS");
  723. if (err != OK) {
  724. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), tmp_app_path_name + "/Contents/MacOS"));
  725. }
  726. }
  727. if (err == OK) {
  728. print_verbose("Creating " + tmp_app_path_name + "/Contents/Frameworks");
  729. err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/Frameworks");
  730. if (err != OK) {
  731. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), tmp_app_path_name + "/Contents/Frameworks"));
  732. }
  733. }
  734. if ((err == OK) && helpers.size() > 0) {
  735. print_line("Creating " + tmp_app_path_name + "/Contents/Helpers");
  736. err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/Helpers");
  737. if (err != OK) {
  738. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), tmp_app_path_name + "/Contents/Helpers"));
  739. }
  740. }
  741. if (err == OK) {
  742. print_verbose("Creating " + tmp_app_path_name + "/Contents/Resources");
  743. err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/Resources");
  744. if (err != OK) {
  745. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), tmp_app_path_name + "/Contents/Resources"));
  746. }
  747. }
  748. Dictionary appnames = ProjectSettings::get_singleton()->get("application/config/name_localized");
  749. Dictionary microphone_usage_descriptions = p_preset->get("privacy/microphone_usage_description_localized");
  750. Dictionary camera_usage_descriptions = p_preset->get("privacy/camera_usage_description_localized");
  751. Dictionary location_usage_descriptions = p_preset->get("privacy/location_usage_description_localized");
  752. Dictionary address_book_usage_descriptions = p_preset->get("privacy/address_book_usage_description_localized");
  753. Dictionary calendar_usage_descriptions = p_preset->get("privacy/calendar_usage_description_localized");
  754. Dictionary photos_library_usage_descriptions = p_preset->get("privacy/photos_library_usage_description_localized");
  755. Dictionary desktop_folder_usage_descriptions = p_preset->get("privacy/desktop_folder_usage_description_localized");
  756. Dictionary documents_folder_usage_descriptions = p_preset->get("privacy/documents_folder_usage_description_localized");
  757. Dictionary downloads_folder_usage_descriptions = p_preset->get("privacy/downloads_folder_usage_description_localized");
  758. Dictionary network_volumes_usage_descriptions = p_preset->get("privacy/network_volumes_usage_description_localized");
  759. Dictionary removable_volumes_usage_descriptions = p_preset->get("privacy/removable_volumes_usage_description_localized");
  760. Dictionary copyrights = p_preset->get("application/copyright_localized");
  761. Vector<String> translations = ProjectSettings::get_singleton()->get("internationalization/locale/translations");
  762. if (translations.size() > 0) {
  763. {
  764. String fname = tmp_app_path_name + "/Contents/Resources/en.lproj";
  765. tmp_app_dir->make_dir_recursive(fname);
  766. Ref<FileAccess> f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE);
  767. f->store_line("/* Localized versions of Info.plist keys */");
  768. f->store_line("");
  769. f->store_line("CFBundleDisplayName = \"" + ProjectSettings::get_singleton()->get("application/config/name").operator String() + "\";");
  770. if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) {
  771. f->store_line("NSMicrophoneUsageDescription = \"" + p_preset->get("privacy/microphone_usage_description").operator String() + "\";");
  772. }
  773. if (!((String)p_preset->get("privacy/camera_usage_description")).is_empty()) {
  774. f->store_line("NSCameraUsageDescription = \"" + p_preset->get("privacy/camera_usage_description").operator String() + "\";");
  775. }
  776. if (!((String)p_preset->get("privacy/location_usage_description")).is_empty()) {
  777. f->store_line("NSLocationUsageDescription = \"" + p_preset->get("privacy/location_usage_description").operator String() + "\";");
  778. }
  779. if (!((String)p_preset->get("privacy/address_book_usage_description")).is_empty()) {
  780. f->store_line("NSContactsUsageDescription = \"" + p_preset->get("privacy/address_book_usage_description").operator String() + "\";");
  781. }
  782. if (!((String)p_preset->get("privacy/calendar_usage_description")).is_empty()) {
  783. f->store_line("NSCalendarsUsageDescription = \"" + p_preset->get("privacy/calendar_usage_description").operator String() + "\";");
  784. }
  785. if (!((String)p_preset->get("privacy/photos_library_usage_description")).is_empty()) {
  786. f->store_line("NSPhotoLibraryUsageDescription = \"" + p_preset->get("privacy/photos_library_usage_description").operator String() + "\";");
  787. }
  788. if (!((String)p_preset->get("privacy/desktop_folder_usage_description")).is_empty()) {
  789. f->store_line("NSDesktopFolderUsageDescription = \"" + p_preset->get("privacy/desktop_folder_usage_description").operator String() + "\";");
  790. }
  791. if (!((String)p_preset->get("privacy/documents_folder_usage_description")).is_empty()) {
  792. f->store_line("NSDocumentsFolderUsageDescription = \"" + p_preset->get("privacy/documents_folder_usage_description").operator String() + "\";");
  793. }
  794. if (!((String)p_preset->get("privacy/downloads_folder_usage_description")).is_empty()) {
  795. f->store_line("NSDownloadsFolderUsageDescription = \"" + p_preset->get("privacy/downloads_folder_usage_description").operator String() + "\";");
  796. }
  797. if (!((String)p_preset->get("privacy/network_volumes_usage_description")).is_empty()) {
  798. f->store_line("NSNetworkVolumesUsageDescription = \"" + p_preset->get("privacy/network_volumes_usage_description").operator String() + "\";");
  799. }
  800. if (!((String)p_preset->get("privacy/removable_volumes_usage_description")).is_empty()) {
  801. f->store_line("NSRemovableVolumesUsageDescription = \"" + p_preset->get("privacy/removable_volumes_usage_description").operator String() + "\";");
  802. }
  803. f->store_line("NSHumanReadableCopyright = \"" + p_preset->get("application/copyright").operator String() + "\";");
  804. }
  805. for (const String &E : translations) {
  806. Ref<Translation> tr = ResourceLoader::load(E);
  807. if (tr.is_valid()) {
  808. String lang = tr->get_locale();
  809. String fname = tmp_app_path_name + "/Contents/Resources/" + lang + ".lproj";
  810. tmp_app_dir->make_dir_recursive(fname);
  811. Ref<FileAccess> f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE);
  812. f->store_line("/* Localized versions of Info.plist keys */");
  813. f->store_line("");
  814. if (appnames.has(lang)) {
  815. f->store_line("CFBundleDisplayName = \"" + appnames[lang].operator String() + "\";");
  816. }
  817. if (microphone_usage_descriptions.has(lang)) {
  818. f->store_line("NSMicrophoneUsageDescription = \"" + microphone_usage_descriptions[lang].operator String() + "\";");
  819. }
  820. if (camera_usage_descriptions.has(lang)) {
  821. f->store_line("NSCameraUsageDescription = \"" + camera_usage_descriptions[lang].operator String() + "\";");
  822. }
  823. if (location_usage_descriptions.has(lang)) {
  824. f->store_line("NSLocationUsageDescription = \"" + location_usage_descriptions[lang].operator String() + "\";");
  825. }
  826. if (address_book_usage_descriptions.has(lang)) {
  827. f->store_line("NSContactsUsageDescription = \"" + address_book_usage_descriptions[lang].operator String() + "\";");
  828. }
  829. if (calendar_usage_descriptions.has(lang)) {
  830. f->store_line("NSCalendarsUsageDescription = \"" + calendar_usage_descriptions[lang].operator String() + "\";");
  831. }
  832. if (photos_library_usage_descriptions.has(lang)) {
  833. f->store_line("NSPhotoLibraryUsageDescription = \"" + photos_library_usage_descriptions[lang].operator String() + "\";");
  834. }
  835. if (desktop_folder_usage_descriptions.has(lang)) {
  836. f->store_line("NSDesktopFolderUsageDescription = \"" + desktop_folder_usage_descriptions[lang].operator String() + "\";");
  837. }
  838. if (documents_folder_usage_descriptions.has(lang)) {
  839. f->store_line("NSDocumentsFolderUsageDescription = \"" + documents_folder_usage_descriptions[lang].operator String() + "\";");
  840. }
  841. if (downloads_folder_usage_descriptions.has(lang)) {
  842. f->store_line("NSDownloadsFolderUsageDescription = \"" + downloads_folder_usage_descriptions[lang].operator String() + "\";");
  843. }
  844. if (network_volumes_usage_descriptions.has(lang)) {
  845. f->store_line("NSNetworkVolumesUsageDescription = \"" + network_volumes_usage_descriptions[lang].operator String() + "\";");
  846. }
  847. if (removable_volumes_usage_descriptions.has(lang)) {
  848. f->store_line("NSRemovableVolumesUsageDescription = \"" + removable_volumes_usage_descriptions[lang].operator String() + "\";");
  849. }
  850. if (copyrights.has(lang)) {
  851. f->store_line("NSHumanReadableCopyright = \"" + copyrights[lang].operator String() + "\";");
  852. }
  853. }
  854. }
  855. }
  856. // Now process our template.
  857. bool found_binary = false;
  858. Vector<String> dylibs_found;
  859. while (ret == UNZ_OK && err == OK) {
  860. bool is_execute = false;
  861. // Get filename.
  862. unz_file_info info;
  863. char fname[16384];
  864. ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, nullptr, 0, nullptr, 0);
  865. if (ret != UNZ_OK) {
  866. break;
  867. }
  868. String file = String::utf8(fname);
  869. Vector<uint8_t> data;
  870. data.resize(info.uncompressed_size);
  871. // Read.
  872. unzOpenCurrentFile(src_pkg_zip);
  873. unzReadCurrentFile(src_pkg_zip, data.ptrw(), data.size());
  874. unzCloseCurrentFile(src_pkg_zip);
  875. // Write.
  876. file = file.replace_first("macos_template.app/", "");
  877. if (((info.external_fa >> 16L) & 0120000) == 0120000) {
  878. #ifndef UNIX_ENABLED
  879. add_message(EXPORT_MESSAGE_INFO, TTR("Export"), TTR("Relative symlinks are not supported on this OS, the exported project might be broken!"));
  880. #endif
  881. // Handle symlinks in the archive.
  882. file = tmp_app_path_name.plus_file(file);
  883. if (err == OK) {
  884. err = tmp_app_dir->make_dir_recursive(file.get_base_dir());
  885. if (err != OK) {
  886. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), file.get_base_dir()));
  887. }
  888. }
  889. if (err == OK) {
  890. String lnk_data = String::utf8((const char *)data.ptr(), data.size());
  891. err = tmp_app_dir->create_link(lnk_data, file);
  892. if (err != OK) {
  893. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not created symlink \"%s\" -> \"%s\"."), lnk_data, file));
  894. }
  895. print_verbose(vformat("ADDING SYMLINK %s => %s\n", file, lnk_data));
  896. }
  897. ret = unzGoToNextFile(src_pkg_zip);
  898. continue; // next
  899. }
  900. if (file == "Contents/Info.plist") {
  901. _fix_plist(p_preset, data, pkg_name);
  902. }
  903. if (file.begins_with("Contents/MacOS/godot_")) {
  904. if (file != "Contents/MacOS/" + binary_to_use) {
  905. ret = unzGoToNextFile(src_pkg_zip);
  906. continue; // skip
  907. }
  908. found_binary = true;
  909. is_execute = true;
  910. file = "Contents/MacOS/" + pkg_name;
  911. }
  912. if (file == "Contents/Resources/icon.icns") {
  913. // See if there is an icon.
  914. String iconpath;
  915. if (p_preset->get("application/icon") != "") {
  916. iconpath = p_preset->get("application/icon");
  917. } else {
  918. iconpath = ProjectSettings::get_singleton()->get("application/config/icon");
  919. }
  920. if (!iconpath.is_empty()) {
  921. if (iconpath.get_extension() == "icns") {
  922. Ref<FileAccess> icon = FileAccess::open(iconpath, FileAccess::READ);
  923. if (icon.is_valid()) {
  924. data.resize(icon->get_length());
  925. icon->get_buffer(&data.write[0], icon->get_length());
  926. }
  927. } else {
  928. Ref<Image> icon;
  929. icon.instantiate();
  930. icon->load(iconpath);
  931. if (!icon->is_empty()) {
  932. _make_icon(icon, data);
  933. }
  934. }
  935. }
  936. }
  937. if (data.size() > 0) {
  938. if (file.find("/data.mono.macos.release_debug." + architecture + "/") != -1) {
  939. if (!p_debug) {
  940. ret = unzGoToNextFile(src_pkg_zip);
  941. continue; // skip
  942. }
  943. file = file.replace("/data.mono.macos.release_debug." + architecture + "/", "/GodotSharp/");
  944. }
  945. if (file.find("/data.mono.macos.release." + architecture + "/") != -1) {
  946. if (p_debug) {
  947. ret = unzGoToNextFile(src_pkg_zip);
  948. continue; // skip
  949. }
  950. file = file.replace("/data.mono.macos.release." + architecture + "/", "/GodotSharp/");
  951. }
  952. if (file.ends_with(".dylib")) {
  953. dylibs_found.push_back(file);
  954. }
  955. print_verbose("ADDING: " + file + " size: " + itos(data.size()));
  956. // Write it into our application bundle.
  957. file = tmp_app_path_name.plus_file(file);
  958. if (err == OK) {
  959. err = tmp_app_dir->make_dir_recursive(file.get_base_dir());
  960. if (err != OK) {
  961. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not create directory \"%s\"."), file.get_base_dir()));
  962. }
  963. }
  964. if (err == OK) {
  965. Ref<FileAccess> f = FileAccess::open(file, FileAccess::WRITE);
  966. if (f.is_valid()) {
  967. f->store_buffer(data.ptr(), data.size());
  968. f.unref();
  969. if (is_execute) {
  970. // chmod with 0755 if the file is executable.
  971. FileAccess::set_unix_permissions(file, 0755);
  972. }
  973. } else {
  974. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not open \"%s\"."), file));
  975. err = ERR_CANT_CREATE;
  976. }
  977. }
  978. }
  979. ret = unzGoToNextFile(src_pkg_zip);
  980. }
  981. // We're done with our source zip.
  982. unzClose(src_pkg_zip);
  983. if (!found_binary) {
  984. 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));
  985. err = ERR_FILE_NOT_FOUND;
  986. }
  987. // Save console script.
  988. if (err == OK) {
  989. int con_scr = p_preset->get("debug/export_console_script");
  990. if ((con_scr == 1 && p_debug) || (con_scr == 2)) {
  991. err = _export_debug_script(p_preset, pkg_name, tmp_app_path_name.get_file() + "/Contents/MacOS/" + pkg_name, scr_path);
  992. FileAccess::set_unix_permissions(scr_path, 0755);
  993. if (err != OK) {
  994. add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Could not create console script."));
  995. }
  996. }
  997. }
  998. if (err == OK) {
  999. if (ep.step(TTR("Making PKG"), 1)) {
  1000. return ERR_SKIP;
  1001. }
  1002. String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck";
  1003. Vector<SharedObject> shared_objects;
  1004. err = save_pack(p_preset, p_debug, pack_path, &shared_objects);
  1005. // See if we can code sign our new package.
  1006. bool sign_enabled = p_preset->get("codesign/enable");
  1007. String ent_path = p_preset->get("codesign/entitlements/custom_file");
  1008. String hlp_ent_path = EditorPaths::get_singleton()->get_cache_dir().plus_file(pkg_name + "_helper.entitlements");
  1009. if (sign_enabled && (ent_path.is_empty())) {
  1010. ent_path = EditorPaths::get_singleton()->get_cache_dir().plus_file(pkg_name + ".entitlements");
  1011. Ref<FileAccess> ent_f = FileAccess::open(ent_path, FileAccess::WRITE);
  1012. if (ent_f.is_valid()) {
  1013. ent_f->store_line("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  1014. ent_f->store_line("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
  1015. ent_f->store_line("<plist version=\"1.0\">");
  1016. ent_f->store_line("<dict>");
  1017. if (Engine::get_singleton()->has_singleton("GodotSharp")) {
  1018. // These entitlements are required to run managed code, and are always enabled in Mono builds.
  1019. ent_f->store_line("<key>com.apple.security.cs.allow-jit</key>");
  1020. ent_f->store_line("<true/>");
  1021. ent_f->store_line("<key>com.apple.security.cs.allow-unsigned-executable-memory</key>");
  1022. ent_f->store_line("<true/>");
  1023. ent_f->store_line("<key>com.apple.security.cs.allow-dyld-environment-variables</key>");
  1024. ent_f->store_line("<true/>");
  1025. } else {
  1026. if ((bool)p_preset->get("codesign/entitlements/allow_jit_code_execution")) {
  1027. ent_f->store_line("<key>com.apple.security.cs.allow-jit</key>");
  1028. ent_f->store_line("<true/>");
  1029. }
  1030. if ((bool)p_preset->get("codesign/entitlements/allow_unsigned_executable_memory")) {
  1031. ent_f->store_line("<key>com.apple.security.cs.allow-unsigned-executable-memory</key>");
  1032. ent_f->store_line("<true/>");
  1033. }
  1034. if ((bool)p_preset->get("codesign/entitlements/allow_dyld_environment_variables")) {
  1035. ent_f->store_line("<key>com.apple.security.cs.allow-dyld-environment-variables</key>");
  1036. ent_f->store_line("<true/>");
  1037. }
  1038. }
  1039. if ((bool)p_preset->get("codesign/entitlements/disable_library_validation")) {
  1040. ent_f->store_line("<key>com.apple.security.cs.disable-library-validation</key>");
  1041. ent_f->store_line("<true/>");
  1042. }
  1043. if ((bool)p_preset->get("codesign/entitlements/audio_input")) {
  1044. ent_f->store_line("<key>com.apple.security.device.audio-input</key>");
  1045. ent_f->store_line("<true/>");
  1046. }
  1047. if ((bool)p_preset->get("codesign/entitlements/camera")) {
  1048. ent_f->store_line("<key>com.apple.security.device.camera</key>");
  1049. ent_f->store_line("<true/>");
  1050. }
  1051. if ((bool)p_preset->get("codesign/entitlements/location")) {
  1052. ent_f->store_line("<key>com.apple.security.personal-information.location</key>");
  1053. ent_f->store_line("<true/>");
  1054. }
  1055. if ((bool)p_preset->get("codesign/entitlements/address_book")) {
  1056. ent_f->store_line("<key>com.apple.security.personal-information.addressbook</key>");
  1057. ent_f->store_line("<true/>");
  1058. }
  1059. if ((bool)p_preset->get("codesign/entitlements/calendars")) {
  1060. ent_f->store_line("<key>com.apple.security.personal-information.calendars</key>");
  1061. ent_f->store_line("<true/>");
  1062. }
  1063. if ((bool)p_preset->get("codesign/entitlements/photos_library")) {
  1064. ent_f->store_line("<key>com.apple.security.personal-information.photos-library</key>");
  1065. ent_f->store_line("<true/>");
  1066. }
  1067. if ((bool)p_preset->get("codesign/entitlements/apple_events")) {
  1068. ent_f->store_line("<key>com.apple.security.automation.apple-events</key>");
  1069. ent_f->store_line("<true/>");
  1070. }
  1071. if ((bool)p_preset->get("codesign/entitlements/debugging")) {
  1072. ent_f->store_line("<key>com.apple.security.get-task-allow</key>");
  1073. ent_f->store_line("<true/>");
  1074. }
  1075. if ((bool)p_preset->get("codesign/entitlements/app_sandbox/enabled")) {
  1076. ent_f->store_line("<key>com.apple.security.app-sandbox</key>");
  1077. ent_f->store_line("<true/>");
  1078. if ((bool)p_preset->get("codesign/entitlements/app_sandbox/network_server")) {
  1079. ent_f->store_line("<key>com.apple.security.network.server</key>");
  1080. ent_f->store_line("<true/>");
  1081. }
  1082. if ((bool)p_preset->get("codesign/entitlements/app_sandbox/network_client")) {
  1083. ent_f->store_line("<key>com.apple.security.network.client</key>");
  1084. ent_f->store_line("<true/>");
  1085. }
  1086. if ((bool)p_preset->get("codesign/entitlements/app_sandbox/device_usb")) {
  1087. ent_f->store_line("<key>com.apple.security.device.usb</key>");
  1088. ent_f->store_line("<true/>");
  1089. }
  1090. if ((bool)p_preset->get("codesign/entitlements/app_sandbox/device_bluetooth")) {
  1091. ent_f->store_line("<key>com.apple.security.device.bluetooth</key>");
  1092. ent_f->store_line("<true/>");
  1093. }
  1094. if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_downloads") == 1) {
  1095. ent_f->store_line("<key>com.apple.security.files.downloads.read-only</key>");
  1096. ent_f->store_line("<true/>");
  1097. }
  1098. if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_downloads") == 2) {
  1099. ent_f->store_line("<key>com.apple.security.files.downloads.read-write</key>");
  1100. ent_f->store_line("<true/>");
  1101. }
  1102. if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_pictures") == 1) {
  1103. ent_f->store_line("<key>com.apple.security.files.pictures.read-only</key>");
  1104. ent_f->store_line("<true/>");
  1105. }
  1106. if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_pictures") == 2) {
  1107. ent_f->store_line("<key>com.apple.security.files.pictures.read-write</key>");
  1108. ent_f->store_line("<true/>");
  1109. }
  1110. if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_music") == 1) {
  1111. ent_f->store_line("<key>com.apple.security.files.music.read-only</key>");
  1112. ent_f->store_line("<true/>");
  1113. }
  1114. if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_music") == 2) {
  1115. ent_f->store_line("<key>com.apple.security.files.music.read-write</key>");
  1116. ent_f->store_line("<true/>");
  1117. }
  1118. if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_movies") == 1) {
  1119. ent_f->store_line("<key>com.apple.security.files.movies.read-only</key>");
  1120. ent_f->store_line("<true/>");
  1121. }
  1122. if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_movies") == 2) {
  1123. ent_f->store_line("<key>com.apple.security.files.movies.read-write</key>");
  1124. ent_f->store_line("<true/>");
  1125. }
  1126. }
  1127. ent_f->store_line("</dict>");
  1128. ent_f->store_line("</plist>");
  1129. } else {
  1130. add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("Could not create entitlements file."));
  1131. err = ERR_CANT_CREATE;
  1132. }
  1133. if ((err == OK) && helpers.size() > 0) {
  1134. ent_f = FileAccess::open(hlp_ent_path, FileAccess::WRITE);
  1135. if (ent_f.is_valid()) {
  1136. ent_f->store_line("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  1137. ent_f->store_line("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
  1138. ent_f->store_line("<plist version=\"1.0\">");
  1139. ent_f->store_line("<dict>");
  1140. ent_f->store_line("<key>com.apple.security.app-sandbox</key>");
  1141. ent_f->store_line("<true/>");
  1142. ent_f->store_line("<key>com.apple.security.inherit</key>");
  1143. ent_f->store_line("<true/>");
  1144. ent_f->store_line("</dict>");
  1145. ent_f->store_line("</plist>");
  1146. } else {
  1147. add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("Could not create helper entitlements file."));
  1148. err = ERR_CANT_CREATE;
  1149. }
  1150. }
  1151. }
  1152. if ((err == OK) && helpers.size() > 0) {
  1153. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  1154. for (int i = 0; i < helpers.size(); i++) {
  1155. String hlp_path = helpers[i];
  1156. err = da->copy(hlp_path, tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file());
  1157. if (err == OK && sign_enabled) {
  1158. err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file(), hlp_ent_path, false);
  1159. }
  1160. FileAccess::set_unix_permissions(tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file(), 0755);
  1161. }
  1162. }
  1163. bool ad_hoc = true;
  1164. if (err == OK) {
  1165. #ifdef MACOS_ENABLED
  1166. String sign_identity = p_preset->get("codesign/identity");
  1167. #else
  1168. String sign_identity = "-";
  1169. #endif
  1170. ad_hoc = (sign_identity == "" || sign_identity == "-");
  1171. bool lib_validation = p_preset->get("codesign/entitlements/disable_library_validation");
  1172. if ((!dylibs_found.is_empty() || !shared_objects.is_empty()) && sign_enabled && ad_hoc && !lib_validation) {
  1173. add_message(EXPORT_MESSAGE_ERROR, TTR("Code Signing"), TTR("Ad-hoc signed applications require the 'Disable Library Validation' entitlement to load dynamic libraries."));
  1174. err = ERR_CANT_CREATE;
  1175. }
  1176. }
  1177. if (err == OK) {
  1178. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  1179. for (int i = 0; i < shared_objects.size(); i++) {
  1180. String src_path = ProjectSettings::get_singleton()->globalize_path(shared_objects[i].path);
  1181. if (shared_objects[i].target.is_empty()) {
  1182. String path_in_app = tmp_app_path_name + "/Contents/Frameworks/" + src_path.get_file();
  1183. err = _copy_and_sign_files(da, src_path, path_in_app, sign_enabled, p_preset, ent_path, true);
  1184. } else {
  1185. String path_in_app = tmp_app_path_name.plus_file(shared_objects[i].target).plus_file(src_path.get_file());
  1186. err = _copy_and_sign_files(da, src_path, path_in_app, sign_enabled, p_preset, ent_path, false);
  1187. }
  1188. if (err != OK) {
  1189. break;
  1190. }
  1191. }
  1192. Vector<Ref<EditorExportPlugin>> export_plugins{ EditorExport::get_singleton()->get_export_plugins() };
  1193. for (int i = 0; i < export_plugins.size(); ++i) {
  1194. err = _export_macos_plugins_for(export_plugins[i], tmp_app_path_name, da, sign_enabled, p_preset, ent_path);
  1195. if (err != OK) {
  1196. break;
  1197. }
  1198. }
  1199. }
  1200. if (sign_enabled) {
  1201. for (int i = 0; i < dylibs_found.size(); i++) {
  1202. if (err == OK) {
  1203. err = _code_sign(p_preset, tmp_app_path_name + "/" + dylibs_found[i], ent_path, false);
  1204. }
  1205. }
  1206. }
  1207. if (err == OK && sign_enabled) {
  1208. if (ep.step(TTR("Code signing bundle"), 2)) {
  1209. return ERR_SKIP;
  1210. }
  1211. err = _code_sign(p_preset, tmp_app_path_name, ent_path);
  1212. }
  1213. if (export_format == "dmg") {
  1214. // Create a DMG.
  1215. if (err == OK) {
  1216. if (ep.step(TTR("Making DMG"), 3)) {
  1217. return ERR_SKIP;
  1218. }
  1219. err = _create_dmg(p_path, pkg_name, tmp_base_path_name);
  1220. }
  1221. // Sign DMG.
  1222. if (err == OK && sign_enabled && !ad_hoc) {
  1223. if (ep.step(TTR("Code signing DMG"), 3)) {
  1224. return ERR_SKIP;
  1225. }
  1226. err = _code_sign(p_preset, p_path, ent_path, false);
  1227. }
  1228. } else if (export_format == "zip") {
  1229. // Create ZIP.
  1230. if (err == OK) {
  1231. if (ep.step(TTR("Making ZIP"), 3)) {
  1232. return ERR_SKIP;
  1233. }
  1234. if (FileAccess::exists(p_path)) {
  1235. OS::get_singleton()->move_to_trash(p_path);
  1236. }
  1237. Ref<FileAccess> io_fa_dst;
  1238. zlib_filefunc_def io_dst = zipio_create_io(&io_fa_dst);
  1239. zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io_dst);
  1240. _zip_folder_recursive(zip, tmp_base_path_name, "", pkg_name);
  1241. zipClose(zip, nullptr);
  1242. }
  1243. }
  1244. #ifdef MACOS_ENABLED
  1245. bool noto_enabled = p_preset->get("notarization/enable");
  1246. if (err == OK && noto_enabled) {
  1247. if (export_format == "app") {
  1248. add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("Notarization requires the app to be archived first, select the DMG or ZIP export format instead."));
  1249. } else {
  1250. if (ep.step(TTR("Sending archive for notarization"), 4)) {
  1251. return ERR_SKIP;
  1252. }
  1253. err = _notarize(p_preset, p_path);
  1254. }
  1255. }
  1256. #endif
  1257. // Clean up temporary entitlements files.
  1258. DirAccess::remove_file_or_error(hlp_ent_path);
  1259. // Clean up temporary .app dir and generated entitlements.
  1260. if ((String)(p_preset->get("codesign/entitlements/custom_file")) == "") {
  1261. tmp_app_dir->remove(ent_path);
  1262. }
  1263. if (export_format != "app") {
  1264. if (tmp_app_dir->change_dir(tmp_base_path_name) == OK) {
  1265. tmp_app_dir->erase_contents_recursive();
  1266. tmp_app_dir->change_dir("..");
  1267. tmp_app_dir->remove(pkg_name);
  1268. }
  1269. }
  1270. }
  1271. return err;
  1272. }
  1273. void EditorExportPlatformMacOS::_zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name) {
  1274. String dir = p_folder.is_empty() ? p_root_path : p_root_path.plus_file(p_folder);
  1275. Ref<DirAccess> da = DirAccess::open(dir);
  1276. da->list_dir_begin();
  1277. String f = da->get_next();
  1278. while (!f.is_empty()) {
  1279. if (f == "." || f == "..") {
  1280. f = da->get_next();
  1281. continue;
  1282. }
  1283. if (da->is_link(f)) {
  1284. OS::Time time = OS::get_singleton()->get_time();
  1285. OS::Date date = OS::get_singleton()->get_date();
  1286. zip_fileinfo zipfi;
  1287. zipfi.tmz_date.tm_hour = time.hour;
  1288. zipfi.tmz_date.tm_mday = date.day;
  1289. zipfi.tmz_date.tm_min = time.minute;
  1290. zipfi.tmz_date.tm_mon = date.month - 1; // Note: "tm" month range - 0..11, Godot month range - 1..12, https://www.cplusplus.com/reference/ctime/tm/
  1291. zipfi.tmz_date.tm_sec = time.second;
  1292. zipfi.tmz_date.tm_year = date.year;
  1293. zipfi.dosDate = 0;
  1294. // 0120000: symbolic link type
  1295. // 0000755: permissions rwxr-xr-x
  1296. // 0000644: permissions rw-r--r--
  1297. uint32_t _mode = 0120644;
  1298. zipfi.external_fa = (_mode << 16L) | !(_mode & 0200);
  1299. zipfi.internal_fa = 0;
  1300. zipOpenNewFileInZip4(p_zip,
  1301. p_folder.plus_file(f).utf8().get_data(),
  1302. &zipfi,
  1303. nullptr,
  1304. 0,
  1305. nullptr,
  1306. 0,
  1307. nullptr,
  1308. Z_DEFLATED,
  1309. Z_DEFAULT_COMPRESSION,
  1310. 0,
  1311. -MAX_WBITS,
  1312. DEF_MEM_LEVEL,
  1313. Z_DEFAULT_STRATEGY,
  1314. nullptr,
  1315. 0,
  1316. 0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions
  1317. 0);
  1318. String target = da->read_link(f);
  1319. zipWriteInFileInZip(p_zip, target.utf8().get_data(), target.utf8().size());
  1320. zipCloseFileInZip(p_zip);
  1321. } else if (da->current_is_dir()) {
  1322. _zip_folder_recursive(p_zip, p_root_path, p_folder.plus_file(f), p_pkg_name);
  1323. } else {
  1324. bool is_executable = (p_folder.ends_with("MacOS") && (f == p_pkg_name)) || p_folder.ends_with("Helpers") || f.ends_with(".command");
  1325. OS::Time time = OS::get_singleton()->get_time();
  1326. OS::Date date = OS::get_singleton()->get_date();
  1327. zip_fileinfo zipfi;
  1328. zipfi.tmz_date.tm_hour = time.hour;
  1329. zipfi.tmz_date.tm_mday = date.day;
  1330. zipfi.tmz_date.tm_min = time.minute;
  1331. zipfi.tmz_date.tm_mon = date.month - 1; // Note: "tm" month range - 0..11, Godot month range - 1..12, https://www.cplusplus.com/reference/ctime/tm/
  1332. zipfi.tmz_date.tm_sec = time.second;
  1333. zipfi.tmz_date.tm_year = date.year;
  1334. zipfi.dosDate = 0;
  1335. // 0100000: regular file type
  1336. // 0000755: permissions rwxr-xr-x
  1337. // 0000644: permissions rw-r--r--
  1338. uint32_t _mode = (is_executable ? 0100755 : 0100644);
  1339. zipfi.external_fa = (_mode << 16L) | !(_mode & 0200);
  1340. zipfi.internal_fa = 0;
  1341. zipOpenNewFileInZip4(p_zip,
  1342. p_folder.plus_file(f).utf8().get_data(),
  1343. &zipfi,
  1344. nullptr,
  1345. 0,
  1346. nullptr,
  1347. 0,
  1348. nullptr,
  1349. Z_DEFLATED,
  1350. Z_DEFAULT_COMPRESSION,
  1351. 0,
  1352. -MAX_WBITS,
  1353. DEF_MEM_LEVEL,
  1354. Z_DEFAULT_STRATEGY,
  1355. nullptr,
  1356. 0,
  1357. 0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions
  1358. 0);
  1359. Ref<FileAccess> fa = FileAccess::open(dir.plus_file(f), FileAccess::READ);
  1360. if (fa.is_null()) {
  1361. add_message(EXPORT_MESSAGE_ERROR, TTR("ZIP Creation"), vformat(TTR("Could not open file to read from path \"%s\"."), dir.plus_file(f)));
  1362. return;
  1363. }
  1364. const int bufsize = 16384;
  1365. uint8_t buf[bufsize];
  1366. while (true) {
  1367. uint64_t got = fa->get_buffer(buf, bufsize);
  1368. if (got == 0) {
  1369. break;
  1370. }
  1371. zipWriteInFileInZip(p_zip, buf, got);
  1372. }
  1373. zipCloseFileInZip(p_zip);
  1374. }
  1375. f = da->get_next();
  1376. }
  1377. da->list_dir_end();
  1378. }
  1379. bool EditorExportPlatformMacOS::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
  1380. String err;
  1381. bool valid = false;
  1382. // Look for export templates (custom templates).
  1383. bool dvalid = false;
  1384. bool rvalid = false;
  1385. if (p_preset->get("custom_template/debug") != "") {
  1386. dvalid = FileAccess::exists(p_preset->get("custom_template/debug"));
  1387. if (!dvalid) {
  1388. err += TTR("Custom debug template not found.") + "\n";
  1389. }
  1390. }
  1391. if (p_preset->get("custom_template/release") != "") {
  1392. rvalid = FileAccess::exists(p_preset->get("custom_template/release"));
  1393. if (!rvalid) {
  1394. err += TTR("Custom release template not found.") + "\n";
  1395. }
  1396. }
  1397. // Look for export templates (official templates, check only is custom templates are not set).
  1398. if (!dvalid || !rvalid) {
  1399. dvalid = exists_export_template("macos.zip", &err);
  1400. rvalid = dvalid; // Both in the same ZIP.
  1401. }
  1402. valid = dvalid || rvalid;
  1403. r_missing_templates = !valid;
  1404. if (!err.is_empty()) {
  1405. r_error = err;
  1406. }
  1407. return valid;
  1408. }
  1409. bool EditorExportPlatformMacOS::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
  1410. String err;
  1411. bool valid = true;
  1412. String identifier = p_preset->get("application/bundle_identifier");
  1413. String pn_err;
  1414. if (!is_package_name_valid(identifier, &pn_err)) {
  1415. err += TTR("Invalid bundle identifier:") + " " + pn_err + "\n";
  1416. valid = false;
  1417. }
  1418. bool sign_enabled = p_preset->get("codesign/enable");
  1419. #ifdef MACOS_ENABLED
  1420. bool noto_enabled = p_preset->get("notarization/enable");
  1421. bool ad_hoc = ((p_preset->get("codesign/identity") == "") || (p_preset->get("codesign/identity") == "-"));
  1422. if (!ad_hoc && (bool)EditorSettings::get_singleton()->get("export/macos/force_builtin_codesign")) {
  1423. err += TTR("Warning: Built-in \"codesign\" is selected in the Editor Settings. Code signing is limited to ad-hoc signature only.") + "\n";
  1424. }
  1425. if (!ad_hoc && !FileAccess::exists("/usr/bin/codesign") && !FileAccess::exists("/bin/codesign")) {
  1426. err += TTR("Warning: Xcode command line tools are not installed, using built-in \"codesign\". Code signing is limited to ad-hoc signature only.") + "\n";
  1427. }
  1428. if (noto_enabled) {
  1429. if (ad_hoc) {
  1430. err += TTR("Notarization: Notarization with an ad-hoc signature is not supported.") + "\n";
  1431. valid = false;
  1432. }
  1433. if (!sign_enabled) {
  1434. err += TTR("Notarization: Code signing is required for notarization.") + "\n";
  1435. valid = false;
  1436. }
  1437. if (!(bool)p_preset->get("codesign/hardened_runtime")) {
  1438. err += TTR("Notarization: Hardened runtime is required for notarization.") + "\n";
  1439. valid = false;
  1440. }
  1441. if (!(bool)p_preset->get("codesign/timestamp")) {
  1442. err += TTR("Notarization: Timestamping is required for notarization.") + "\n";
  1443. valid = false;
  1444. }
  1445. if (p_preset->get("notarization/apple_id_name") == "") {
  1446. err += TTR("Notarization: Apple ID name not specified.") + "\n";
  1447. valid = false;
  1448. }
  1449. if (p_preset->get("notarization/apple_id_password") == "") {
  1450. err += TTR("Notarization: Apple ID password not specified.") + "\n";
  1451. valid = false;
  1452. }
  1453. } else {
  1454. err += TTR("Warning: Notarization is disabled. The exported project will be blocked by Gatekeeper if it's downloaded from an unknown source.") + "\n";
  1455. if (!sign_enabled) {
  1456. err += TTR("Code signing is disabled. The exported project will not run on Macs with enabled Gatekeeper and Apple Silicon powered Macs.") + "\n";
  1457. } else {
  1458. if ((bool)p_preset->get("codesign/hardened_runtime") && ad_hoc) {
  1459. err += TTR("Hardened Runtime is not compatible with ad-hoc signature, and will be disabled!") + "\n";
  1460. }
  1461. if ((bool)p_preset->get("codesign/timestamp") && ad_hoc) {
  1462. err += TTR("Timestamping is not compatible with ad-hoc signature, and will be disabled!") + "\n";
  1463. }
  1464. }
  1465. }
  1466. #else
  1467. err += TTR("Warning: Notarization is not supported from this OS. The exported project will be blocked by Gatekeeper if it's downloaded from an unknown source.") + "\n";
  1468. if (!sign_enabled) {
  1469. err += TTR("Code signing is disabled. The exported project will not run on Macs with enabled Gatekeeper and Apple Silicon powered Macs.") + "\n";
  1470. }
  1471. #endif
  1472. if (sign_enabled) {
  1473. if ((bool)p_preset->get("codesign/entitlements/audio_input") && ((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) {
  1474. err += TTR("Privacy: Microphone access is enabled, but usage description is not specified.") + "\n";
  1475. valid = false;
  1476. }
  1477. if ((bool)p_preset->get("codesign/entitlements/camera") && ((String)p_preset->get("privacy/camera_usage_description")).is_empty()) {
  1478. err += TTR("Privacy: Camera access is enabled, but usage description is not specified.") + "\n";
  1479. valid = false;
  1480. }
  1481. if ((bool)p_preset->get("codesign/entitlements/location") && ((String)p_preset->get("privacy/location_usage_description")).is_empty()) {
  1482. err += TTR("Privacy: Location information access is enabled, but usage description is not specified.") + "\n";
  1483. valid = false;
  1484. }
  1485. if ((bool)p_preset->get("codesign/entitlements/address_book") && ((String)p_preset->get("privacy/address_book_usage_description")).is_empty()) {
  1486. err += TTR("Privacy: Address book access is enabled, but usage description is not specified.") + "\n";
  1487. valid = false;
  1488. }
  1489. if ((bool)p_preset->get("codesign/entitlements/calendars") && ((String)p_preset->get("privacy/calendar_usage_description")).is_empty()) {
  1490. err += TTR("Privacy: Calendar access is enabled, but usage description is not specified.") + "\n";
  1491. valid = false;
  1492. }
  1493. if ((bool)p_preset->get("codesign/entitlements/photos_library") && ((String)p_preset->get("privacy/photos_library_usage_description")).is_empty()) {
  1494. err += TTR("Privacy: Photo library access is enabled, but usage description is not specified.") + "\n";
  1495. valid = false;
  1496. }
  1497. }
  1498. if (!err.is_empty()) {
  1499. r_error = err;
  1500. }
  1501. return valid;
  1502. }
  1503. EditorExportPlatformMacOS::EditorExportPlatformMacOS() {
  1504. logo = ImageTexture::create_from_image(memnew(Image(_macos_logo)));
  1505. }
  1506. EditorExportPlatformMacOS::~EditorExportPlatformMacOS() {
  1507. }