export.cpp 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  1. /*************************************************************************/
  2. /* export.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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.h"
  31. #include "editor/editor_export.h"
  32. #include "editor/editor_node.h"
  33. #include "editor/editor_settings.h"
  34. #include "io/marshalls.h"
  35. #include "io/resource_saver.h"
  36. #include "io/zip_io.h"
  37. #include "os/file_access.h"
  38. #include "os/os.h"
  39. #include "platform/iphone/logo.gen.h"
  40. #include "project_settings.h"
  41. #include "string.h"
  42. #include "version.h"
  43. #include <sys/stat.h>
  44. class EditorExportPlatformIOS : public EditorExportPlatform {
  45. GDCLASS(EditorExportPlatformIOS, EditorExportPlatform);
  46. int version_code;
  47. Ref<ImageTexture> logo;
  48. typedef Error (*FileHandler)(String p_file, void *p_userdata);
  49. static Error _walk_dir_recursive(DirAccess *p_da, FileHandler p_handler, void *p_userdata);
  50. static Error _codesign(String p_file, void *p_userdata);
  51. struct IOSConfigData {
  52. String pkg_name;
  53. String binary_name;
  54. String plist_content;
  55. String architectures;
  56. String linker_flags;
  57. String cpp_code;
  58. };
  59. struct ExportArchitecture {
  60. String name;
  61. bool is_default;
  62. ExportArchitecture() :
  63. name(""),
  64. is_default(false) {
  65. }
  66. ExportArchitecture(String p_name, bool p_is_default) {
  67. name = p_name;
  68. is_default = p_is_default;
  69. }
  70. };
  71. struct IOSExportAsset {
  72. String exported_path;
  73. bool is_framework; // framework is anything linked to the binary, otherwise it's a resource
  74. };
  75. String _get_additional_plist_content();
  76. String _get_linker_flags();
  77. String _get_cpp_code();
  78. void _fix_config_file(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &pfile, const IOSConfigData &p_config, bool p_debug);
  79. Error _export_loading_screens(const Ref<EditorExportPreset> &p_preset, const String &p_dest_dir);
  80. Error _export_icons(const Ref<EditorExportPreset> &p_preset, const String &p_iconset_dir);
  81. Vector<ExportArchitecture> _get_supported_architectures();
  82. Vector<String> _get_preset_architectures(const Ref<EditorExportPreset> &p_preset);
  83. void _add_assets_to_project(Vector<uint8_t> &p_project_data, const Vector<IOSExportAsset> &p_additional_assets);
  84. Error _export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, Vector<IOSExportAsset> &r_exported_assets);
  85. Error _export_additional_assets(const String &p_out_dir, const Vector<SharedObject> &p_libraries, Vector<IOSExportAsset> &r_exported_assets);
  86. protected:
  87. virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
  88. virtual void get_export_options(List<ExportOption> *r_options);
  89. public:
  90. virtual String get_name() const { return "iOS"; }
  91. virtual String get_os_name() const { return "iOS"; }
  92. virtual Ref<Texture> get_logo() const { return logo; }
  93. virtual String get_binary_extension(const Ref<EditorExportPreset> &p_preset) const { return "ipa"; }
  94. virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
  95. virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
  96. virtual void get_platform_features(List<String> *r_features) {
  97. r_features->push_back("mobile");
  98. r_features->push_back("iOS");
  99. }
  100. EditorExportPlatformIOS();
  101. ~EditorExportPlatformIOS();
  102. };
  103. void EditorExportPlatformIOS::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
  104. if (p_preset->get("texture_format/s3tc")) {
  105. r_features->push_back("s3tc");
  106. }
  107. if (p_preset->get("texture_format/etc")) {
  108. r_features->push_back("etc");
  109. }
  110. if (p_preset->get("texture_format/etc2")) {
  111. r_features->push_back("etc2");
  112. }
  113. Vector<String> architectures = _get_preset_architectures(p_preset);
  114. for (int i = 0; i < architectures.size(); ++i) {
  115. r_features->push_back(architectures[i]);
  116. }
  117. }
  118. Vector<EditorExportPlatformIOS::ExportArchitecture> EditorExportPlatformIOS::_get_supported_architectures() {
  119. Vector<ExportArchitecture> archs;
  120. archs.push_back(ExportArchitecture("armv7", true));
  121. archs.push_back(ExportArchitecture("arm64", true));
  122. return archs;
  123. }
  124. void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) {
  125. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "zip"), ""));
  126. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "zip"), ""));
  127. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/app_store_team_id"), ""));
  128. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/provisioning_profile_uuid_debug"), ""));
  129. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/code_sign_identity_debug"), "iPhone Developer"));
  130. r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/export_method_debug", PROPERTY_HINT_ENUM, "App Store,Development,Ad-Hoc,Enterprise"), 1));
  131. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/provisioning_profile_uuid_release"), ""));
  132. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/code_sign_identity_release"), "iPhone Distribution"));
  133. r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/export_method_release", PROPERTY_HINT_ENUM, "App Store,Development,Ad-Hoc,Enterprise"), 0));
  134. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/name"), ""));
  135. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/info"), "Made with Godot Engine"));
  136. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/identifier"), "org.godotengine.iosgame"));
  137. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), "????"));
  138. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version"), "1.0"));
  139. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version"), "1.0"));
  140. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));
  141. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/iphone_120x120", PROPERTY_HINT_FILE, "png"), "")); // Home screen on iPhone/iPod Touch with retina display
  142. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/ipad_76x76", PROPERTY_HINT_FILE, "png"), "")); // Home screen on iPad
  143. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/iphone_180x180", PROPERTY_HINT_FILE, "png"), "")); // Home screen on iPhone with retina HD display
  144. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/ipad_152x152", PROPERTY_HINT_FILE, "png"), "")); // Home screen on iPad with retina display
  145. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/ipad_167x167", PROPERTY_HINT_FILE, "png"), "")); // Home screen on iPad Pro
  146. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_40x40", PROPERTY_HINT_FILE, "png"), "")); // Spotlight
  147. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_80x80", PROPERTY_HINT_FILE, "png"), "")); // Spotlight on devices with retina display
  148. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "landscape_launch_screens/iphone_2208x1242", PROPERTY_HINT_FILE, "png"), "")); // iPhone 6 Plus, 6s Plus, 7 Plus
  149. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "landscape_launch_screens/ipad_2732x2048", PROPERTY_HINT_FILE, "png"), "")); // 12.9-inch iPad Pro
  150. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "landscape_launch_screens/ipad_2048x1536", PROPERTY_HINT_FILE, "png"), "")); // Other iPads
  151. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "portrait_launch_screens/iphone_640x1136", PROPERTY_HINT_FILE, "png"), "")); // iPhone 5, 5s, SE
  152. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "portrait_launch_screens/iphone_750x1334", PROPERTY_HINT_FILE, "png"), "")); // iPhone 6, 6s, 7
  153. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "portrait_launch_screens/iphone_1242x2208", PROPERTY_HINT_FILE, "png"), "")); // iPhone 6 Plus, 6s Plus, 7 Plus
  154. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "portrait_launch_screens/ipad_2048x2732", PROPERTY_HINT_FILE, "png"), "")); // 12.9-inch iPad Pro
  155. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "portrait_launch_screens/ipad_1536x2048", PROPERTY_HINT_FILE, "png"), "")); // Other iPads
  156. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), false));
  157. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
  158. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), true));
  159. Vector<ExportArchitecture> architectures = _get_supported_architectures();
  160. for (int i = 0; i < architectures.size(); ++i) {
  161. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architectures/" + architectures[i].name), architectures[i].is_default));
  162. }
  163. }
  164. void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &pfile, const IOSConfigData &p_config, bool p_debug) {
  165. static const String export_method_string[] = {
  166. "app-store",
  167. "development",
  168. "ad-hoc",
  169. "enterprise"
  170. };
  171. String str;
  172. String strnew;
  173. str.parse_utf8((const char *)pfile.ptr(), pfile.size());
  174. Vector<String> lines = str.split("\n");
  175. for (int i = 0; i < lines.size(); i++) {
  176. if (lines[i].find("$binary") != -1) {
  177. strnew += lines[i].replace("$binary", p_config.binary_name) + "\n";
  178. } else if (lines[i].find("$name") != -1) {
  179. strnew += lines[i].replace("$name", p_config.pkg_name) + "\n";
  180. } else if (lines[i].find("$info") != -1) {
  181. strnew += lines[i].replace("$info", p_preset->get("application/info")) + "\n";
  182. } else if (lines[i].find("$identifier") != -1) {
  183. strnew += lines[i].replace("$identifier", p_preset->get("application/identifier")) + "\n";
  184. } else if (lines[i].find("$short_version") != -1) {
  185. strnew += lines[i].replace("$short_version", p_preset->get("application/short_version")) + "\n";
  186. } else if (lines[i].find("$version") != -1) {
  187. strnew += lines[i].replace("$version", p_preset->get("application/version")) + "\n";
  188. } else if (lines[i].find("$signature") != -1) {
  189. strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n";
  190. } else if (lines[i].find("$copyright") != -1) {
  191. strnew += lines[i].replace("$copyright", p_preset->get("application/copyright")) + "\n";
  192. } else if (lines[i].find("$team_id") != -1) {
  193. strnew += lines[i].replace("$team_id", p_preset->get("application/app_store_team_id")) + "\n";
  194. } else if (lines[i].find("$export_method") != -1) {
  195. int export_method = p_preset->get(p_debug ? "application/export_method_debug" : "application/export_method_release");
  196. strnew += lines[i].replace("$export_method", export_method_string[export_method]) + "\n";
  197. } else if (lines[i].find("$provisioning_profile_uuid_release") != -1) {
  198. strnew += lines[i].replace("$provisioning_profile_uuid_release", p_preset->get("application/provisioning_profile_uuid_release")) + "\n";
  199. } else if (lines[i].find("$provisioning_profile_uuid_debug") != -1) {
  200. strnew += lines[i].replace("$provisioning_profile_uuid_debug", p_preset->get("application/provisioning_profile_uuid_debug")) + "\n";
  201. } else if (lines[i].find("$provisioning_profile_uuid") != -1) {
  202. String uuid = p_debug ? p_preset->get("application/provisioning_profile_uuid_debug") : p_preset->get("application/provisioning_profile_uuid_release");
  203. strnew += lines[i].replace("$provisioning_profile_uuid", uuid) + "\n";
  204. } else if (lines[i].find("$code_sign_identity_debug") != -1) {
  205. strnew += lines[i].replace("$code_sign_identity_debug", p_preset->get("application/code_sign_identity_debug")) + "\n";
  206. } else if (lines[i].find("$code_sign_identity_release") != -1) {
  207. strnew += lines[i].replace("$code_sign_identity_release", p_preset->get("application/code_sign_identity_release")) + "\n";
  208. } else if (lines[i].find("$additional_plist_content") != -1) {
  209. strnew += lines[i].replace("$additional_plist_content", p_config.plist_content) + "\n";
  210. } else if (lines[i].find("$godot_archs") != -1) {
  211. strnew += lines[i].replace("$godot_archs", p_config.architectures) + "\n";
  212. } else if (lines[i].find("$linker_flags") != -1) {
  213. strnew += lines[i].replace("$linker_flags", p_config.linker_flags) + "\n";
  214. } else if (lines[i].find("$cpp_code") != -1) {
  215. strnew += lines[i].replace("$cpp_code", p_config.cpp_code) + "\n";
  216. } else {
  217. strnew += lines[i] + "\n";
  218. }
  219. }
  220. // !BAS! I'm assuming the 9 in the original code was a typo. I've added -1 or else it seems to also be adding our terminating zero...
  221. // should apply the same fix in our OSX export.
  222. CharString cs = strnew.utf8();
  223. pfile.resize(cs.size() - 1);
  224. for (int i = 0; i < cs.size() - 1; i++) {
  225. pfile[i] = cs[i];
  226. }
  227. }
  228. String EditorExportPlatformIOS::_get_additional_plist_content() {
  229. Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
  230. String result;
  231. for (int i = 0; i < export_plugins.size(); ++i) {
  232. result += export_plugins[i]->get_ios_plist_content();
  233. }
  234. return result;
  235. }
  236. String EditorExportPlatformIOS::_get_linker_flags() {
  237. Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
  238. String result;
  239. for (int i = 0; i < export_plugins.size(); ++i) {
  240. String flags = export_plugins[i]->get_ios_linker_flags();
  241. if (flags.length() == 0) continue;
  242. if (result.length() > 0) {
  243. result += ' ';
  244. }
  245. result += flags;
  246. }
  247. // the flags will be enclosed in quotes, so need to escape them
  248. return result.replace("\"", "\\\"");
  249. }
  250. String EditorExportPlatformIOS::_get_cpp_code() {
  251. Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
  252. String result;
  253. for (int i = 0; i < export_plugins.size(); ++i) {
  254. result += export_plugins[i]->get_ios_cpp_code();
  255. }
  256. return result;
  257. }
  258. struct IconInfo {
  259. const char *preset_key;
  260. const char *idiom;
  261. const char *export_name;
  262. const char *actual_size_side;
  263. const char *scale;
  264. const char *unscaled_size;
  265. bool is_required;
  266. };
  267. static const IconInfo icon_infos[] = {
  268. { "required_icons/iphone_120x120", "iphone", "Icon-120.png", "120", "2x", "60x60", true },
  269. { "required_icons/iphone_120x120", "iphone", "Icon-120.png", "120", "3x", "40x40", true },
  270. { "required_icons/ipad_76x76", "ipad", "Icon-76.png", "76", "1x", "76x76", false },
  271. { "optional_icons/iphone_180x180", "iphone", "Icon-180.png", "180", "3x", "60x60", false },
  272. { "optional_icons/ipad_152x152", "ipad", "Icon-152.png", "152", "2x", "76x76", false },
  273. { "optional_icons/ipad_167x167", "ipad", "Icon-167.png", "167", "2x", "83.5x83.5", false },
  274. { "optional_icons/spotlight_40x40", "ipad", "Icon-40.png", "40", "1x", "40x40", false },
  275. { "optional_icons/spotlight_80x80", "iphone", "Icon-80.png", "80", "2x", "40x40", false },
  276. { "optional_icons/spotlight_80x80", "ipad", "Icon-80.png", "80", "2x", "40x40", false }
  277. };
  278. Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_preset, const String &p_iconset_dir) {
  279. String json_description = "{\"images\":[";
  280. String sizes;
  281. DirAccess *da = DirAccess::open(p_iconset_dir);
  282. ERR_FAIL_COND_V(!da, ERR_CANT_OPEN);
  283. for (int i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
  284. IconInfo info = icon_infos[i];
  285. String icon_path = p_preset->get(info.preset_key);
  286. if (icon_path.length() == 0) {
  287. if (info.is_required) {
  288. ERR_PRINT("Required icon is not specified in the preset");
  289. return ERR_UNCONFIGURED;
  290. }
  291. continue;
  292. }
  293. Error err = da->copy(icon_path, p_iconset_dir + info.export_name);
  294. if (err) {
  295. memdelete(da);
  296. String err_str = String("Failed to export icon: ") + icon_path;
  297. ERR_PRINT(err_str.utf8().get_data());
  298. return err;
  299. }
  300. sizes += String(info.actual_size_side) + "\n";
  301. if (i > 0) {
  302. json_description += ",";
  303. }
  304. json_description += String("{");
  305. json_description += String("\"idiom\":") + "\"" + info.idiom + "\",";
  306. json_description += String("\"size\":") + "\"" + info.unscaled_size + "\",";
  307. json_description += String("\"scale\":") + "\"" + info.scale + "\",";
  308. json_description += String("\"filename\":") + "\"" + info.export_name + "\"";
  309. json_description += String("}");
  310. }
  311. json_description += "]}";
  312. memdelete(da);
  313. FileAccess *json_file = FileAccess::open(p_iconset_dir + "Contents.json", FileAccess::WRITE);
  314. ERR_FAIL_COND_V(!json_file, ERR_CANT_CREATE);
  315. CharString json_utf8 = json_description.utf8();
  316. json_file->store_buffer((const uint8_t *)json_utf8.get_data(), json_utf8.length());
  317. memdelete(json_file);
  318. FileAccess *sizes_file = FileAccess::open(p_iconset_dir + "sizes", FileAccess::WRITE);
  319. ERR_FAIL_COND_V(!sizes_file, ERR_CANT_CREATE);
  320. CharString sizes_utf8 = sizes.utf8();
  321. sizes_file->store_buffer((const uint8_t *)sizes_utf8.get_data(), sizes_utf8.length());
  322. memdelete(sizes_file);
  323. return OK;
  324. }
  325. struct LoadingScreenInfo {
  326. const char *preset_key;
  327. const char *export_name;
  328. };
  329. static const LoadingScreenInfo loading_screen_infos[] = {
  330. { "landscape_launch_screens/iphone_2208x1242", "[email protected]" },
  331. { "landscape_launch_screens/ipad_2732x2048", "[email protected]" },
  332. { "landscape_launch_screens/ipad_2048x1536", "[email protected]" },
  333. { "portrait_launch_screens/iphone_640x1136", "[email protected]" },
  334. { "portrait_launch_screens/iphone_750x1334", "[email protected]" },
  335. { "portrait_launch_screens/iphone_1242x2208", "[email protected]" },
  336. { "portrait_launch_screens/ipad_2048x2732", "[email protected]" },
  337. { "portrait_launch_screens/ipad_1536x2048", "[email protected]" }
  338. };
  339. Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPreset> &p_preset, const String &p_dest_dir) {
  340. DirAccess *da = DirAccess::open(p_dest_dir);
  341. ERR_FAIL_COND_V(!da, ERR_CANT_OPEN);
  342. for (int i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) {
  343. LoadingScreenInfo info = loading_screen_infos[i];
  344. String loading_screen_file = p_preset->get(info.preset_key);
  345. Error err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
  346. if (err) {
  347. memdelete(da);
  348. String err_str = String("Failed to export loading screen: ") + loading_screen_file;
  349. ERR_PRINT(err_str.utf8().get_data());
  350. return err;
  351. }
  352. }
  353. memdelete(da);
  354. return OK;
  355. }
  356. Error EditorExportPlatformIOS::_walk_dir_recursive(DirAccess *p_da, FileHandler p_handler, void *p_userdata) {
  357. Vector<String> dirs;
  358. String path;
  359. String current_dir = p_da->get_current_dir();
  360. p_da->list_dir_begin();
  361. while ((path = p_da->get_next()).length() != 0) {
  362. if (p_da->current_is_dir()) {
  363. if (path != "." && path != "..") {
  364. dirs.push_back(path);
  365. }
  366. } else {
  367. Error err = p_handler(current_dir + "/" + path, p_userdata);
  368. if (err) {
  369. p_da->list_dir_end();
  370. return err;
  371. }
  372. }
  373. }
  374. p_da->list_dir_end();
  375. for (int i = 0; i < dirs.size(); ++i) {
  376. String dir = dirs[i];
  377. p_da->change_dir(dir);
  378. Error err = _walk_dir_recursive(p_da, p_handler, p_userdata);
  379. p_da->change_dir("..");
  380. if (err) {
  381. return err;
  382. }
  383. }
  384. return OK;
  385. }
  386. struct CodesignData {
  387. const Ref<EditorExportPreset> &preset;
  388. bool debug;
  389. CodesignData(const Ref<EditorExportPreset> &p_preset, bool p_debug) :
  390. preset(p_preset),
  391. debug(p_debug) {
  392. }
  393. };
  394. Error EditorExportPlatformIOS::_codesign(String p_file, void *p_userdata) {
  395. if (p_file.ends_with(".dylib")) {
  396. CodesignData *data = (CodesignData *)p_userdata;
  397. print_line(String("Signing ") + p_file);
  398. List<String> codesign_args;
  399. codesign_args.push_back("-f");
  400. codesign_args.push_back("-s");
  401. codesign_args.push_back(data->preset->get(data->debug ? "application/code_sign_identity_debug" : "application/code_sign_identity_release"));
  402. codesign_args.push_back(p_file);
  403. return OS::get_singleton()->execute("codesign", codesign_args, true);
  404. }
  405. return OK;
  406. }
  407. struct PbxId {
  408. private:
  409. static char _hex_char(uint8_t four_bits) {
  410. if (four_bits < 10) {
  411. return ('0' + four_bits);
  412. }
  413. return 'A' + (four_bits - 10);
  414. }
  415. static String _hex_pad(uint32_t num) {
  416. Vector<char> ret;
  417. ret.resize(sizeof(num) * 2);
  418. for (int i = 0; i < sizeof(num) * 2; ++i) {
  419. uint8_t four_bits = (num >> (sizeof(num) * 8 - (i + 1) * 4)) & 0xF;
  420. ret[i] = _hex_char(four_bits);
  421. }
  422. return String::utf8(ret.ptr(), ret.size());
  423. }
  424. public:
  425. uint32_t high_bits;
  426. uint32_t mid_bits;
  427. uint32_t low_bits;
  428. String str() const {
  429. return _hex_pad(high_bits) + _hex_pad(mid_bits) + _hex_pad(low_bits);
  430. }
  431. PbxId &operator++() {
  432. low_bits++;
  433. if (!low_bits) {
  434. mid_bits++;
  435. if (!mid_bits) {
  436. high_bits++;
  437. }
  438. }
  439. return *this;
  440. }
  441. };
  442. struct ExportLibsData {
  443. Vector<String> lib_paths;
  444. String dest_dir;
  445. };
  446. void EditorExportPlatformIOS::_add_assets_to_project(Vector<uint8_t> &p_project_data, const Vector<IOSExportAsset> &p_additional_assets) {
  447. Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
  448. Vector<String> frameworks;
  449. for (int i = 0; i < export_plugins.size(); ++i) {
  450. Vector<String> plugin_frameworks = export_plugins[i]->get_ios_frameworks();
  451. for (int j = 0; j < plugin_frameworks.size(); ++j) {
  452. frameworks.push_back(plugin_frameworks[j]);
  453. }
  454. }
  455. // that is just a random number, we just need Godot IDs not to clash with
  456. // existing IDs in the project.
  457. PbxId current_id = { 0x58938401, 0, 0 };
  458. String pbx_files;
  459. String pbx_frameworks_build;
  460. String pbx_frameworks_refs;
  461. String pbx_resources_build;
  462. String pbx_resources_refs;
  463. const String file_info_format = String("$build_id = {isa = PBXBuildFile; fileRef = $ref_id; };\n") +
  464. "$ref_id = {isa = PBXFileReference; lastKnownFileType = $file_type; name = $name; path = \"$file_path\"; sourceTree = \"<group>\"; };\n";
  465. for (int i = 0; i < p_additional_assets.size(); ++i) {
  466. String build_id = (++current_id).str();
  467. String ref_id = (++current_id).str();
  468. const IOSExportAsset &asset = p_additional_assets[i];
  469. String type;
  470. if (asset.exported_path.ends_with(".framework")) {
  471. type = "wrapper.framework";
  472. } else if (asset.exported_path.ends_with(".dylib")) {
  473. type = "compiled.mach-o.dylib";
  474. } else if (asset.exported_path.ends_with(".a")) {
  475. type = "archive.ar";
  476. } else {
  477. type = "file";
  478. }
  479. String &pbx_build = asset.is_framework ? pbx_frameworks_build : pbx_resources_build;
  480. String &pbx_refs = asset.is_framework ? pbx_frameworks_refs : pbx_resources_refs;
  481. if (pbx_build.length() > 0) {
  482. pbx_build += ",\n";
  483. pbx_refs += ",\n";
  484. }
  485. pbx_build += build_id;
  486. pbx_refs += ref_id;
  487. Dictionary format_dict;
  488. format_dict["build_id"] = build_id;
  489. format_dict["ref_id"] = ref_id;
  490. format_dict["name"] = asset.exported_path.get_file();
  491. format_dict["file_path"] = asset.exported_path;
  492. format_dict["file_type"] = type;
  493. pbx_files += file_info_format.format(format_dict, "$_");
  494. }
  495. String str = String::utf8((const char *)p_project_data.ptr(), p_project_data.size());
  496. str = str.replace("$additional_pbx_files", pbx_files);
  497. str = str.replace("$additional_pbx_frameworks_build", pbx_frameworks_build);
  498. str = str.replace("$additional_pbx_frameworks_refs", pbx_frameworks_refs);
  499. str = str.replace("$additional_pbx_resources_build", pbx_resources_build);
  500. str = str.replace("$additional_pbx_resources_refs", pbx_resources_refs);
  501. CharString cs = str.utf8();
  502. p_project_data.resize(cs.size() - 1);
  503. for (int i = 0; i < cs.size() - 1; i++) {
  504. p_project_data[i] = cs[i];
  505. }
  506. }
  507. Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, Vector<IOSExportAsset> &r_exported_assets) {
  508. DirAccess *filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  509. ERR_FAIL_COND_V(!filesystem_da, ERR_CANT_CREATE);
  510. for (int f_idx = 0; f_idx < p_assets.size(); ++f_idx) {
  511. String asset = p_assets[f_idx];
  512. if (!asset.begins_with("res://")) {
  513. // either SDK-builtin or already a part of the export template
  514. IOSExportAsset exported_asset = { asset, p_is_framework };
  515. r_exported_assets.push_back(exported_asset);
  516. } else {
  517. DirAccess *da = DirAccess::create_for_path(asset);
  518. if (!da) {
  519. memdelete(filesystem_da);
  520. ERR_FAIL_COND_V(!da, ERR_CANT_CREATE);
  521. }
  522. bool file_exists = da->file_exists(asset);
  523. bool dir_exists = da->dir_exists(asset);
  524. if (!file_exists && !dir_exists) {
  525. memdelete(da);
  526. memdelete(filesystem_da);
  527. return ERR_FILE_NOT_FOUND;
  528. }
  529. String additional_dir = p_is_framework && asset.ends_with(".dylib") ? "/dylibs/" : "/";
  530. String destination_dir = p_out_dir + additional_dir + asset.get_base_dir().replace("res://", "");
  531. if (!filesystem_da->dir_exists(destination_dir)) {
  532. Error make_dir_err = filesystem_da->make_dir_recursive(destination_dir);
  533. if (make_dir_err) {
  534. memdelete(da);
  535. memdelete(filesystem_da);
  536. return make_dir_err;
  537. }
  538. }
  539. String destination = destination_dir + "/" + asset.get_file();
  540. Error err = dir_exists ? da->copy_dir(asset, destination) : da->copy(asset, destination);
  541. memdelete(da);
  542. if (err) {
  543. memdelete(filesystem_da);
  544. return err;
  545. }
  546. IOSExportAsset exported_asset = { destination, p_is_framework };
  547. r_exported_assets.push_back(exported_asset);
  548. }
  549. }
  550. memdelete(filesystem_da);
  551. return OK;
  552. }
  553. Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<SharedObject> &p_libraries, Vector<IOSExportAsset> &r_exported_assets) {
  554. Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
  555. for (int i = 0; i < export_plugins.size(); i++) {
  556. Vector<String> frameworks = export_plugins[i]->get_ios_frameworks();
  557. Error err = _export_additional_assets(p_out_dir, frameworks, true, r_exported_assets);
  558. ERR_FAIL_COND_V(err, err);
  559. Vector<String> ios_bundle_files = export_plugins[i]->get_ios_bundle_files();
  560. err = _export_additional_assets(p_out_dir, ios_bundle_files, false, r_exported_assets);
  561. ERR_FAIL_COND_V(err, err);
  562. }
  563. Vector<String> library_paths;
  564. for (int i = 0; i < p_libraries.size(); ++i) {
  565. library_paths.push_back(p_libraries[i].path);
  566. }
  567. Error err = _export_additional_assets(p_out_dir, library_paths, true, r_exported_assets);
  568. ERR_FAIL_COND_V(err, err);
  569. return OK;
  570. }
  571. Vector<String> EditorExportPlatformIOS::_get_preset_architectures(const Ref<EditorExportPreset> &p_preset) {
  572. Vector<ExportArchitecture> all_archs = _get_supported_architectures();
  573. Vector<String> enabled_archs;
  574. for (int i = 0; i < all_archs.size(); ++i) {
  575. bool is_enabled = p_preset->get("architectures/" + all_archs[i].name);
  576. if (is_enabled) {
  577. enabled_archs.push_back(all_archs[i].name);
  578. }
  579. }
  580. return enabled_archs;
  581. }
  582. Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
  583. ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
  584. String src_pkg_name;
  585. String dest_dir = p_path.get_base_dir() + "/";
  586. String binary_name = p_path.get_file().get_basename();
  587. EditorProgress ep("export", "Exporting for iOS", 5);
  588. String team_id = p_preset->get("application/app_store_team_id");
  589. ERR_EXPLAIN("App Store Team ID not specified - cannot configure the project.");
  590. ERR_FAIL_COND_V(team_id.length() == 0, ERR_CANT_OPEN);
  591. if (p_debug)
  592. src_pkg_name = p_preset->get("custom_package/debug");
  593. else
  594. src_pkg_name = p_preset->get("custom_package/release");
  595. if (src_pkg_name == "") {
  596. String err;
  597. src_pkg_name = find_export_template("iphone.zip", &err);
  598. if (src_pkg_name == "") {
  599. EditorNode::add_io_error(err);
  600. return ERR_FILE_NOT_FOUND;
  601. }
  602. }
  603. DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  604. if (da) {
  605. String current_dir = da->get_current_dir();
  606. // remove leftovers from last export so they don't interfere
  607. // in case some files are no longer needed
  608. if (da->change_dir(dest_dir + binary_name + ".xcodeproj") == OK) {
  609. da->erase_contents_recursive();
  610. }
  611. if (da->change_dir(dest_dir + binary_name) == OK) {
  612. da->erase_contents_recursive();
  613. }
  614. da->change_dir(current_dir);
  615. if (!da->dir_exists(dest_dir + binary_name)) {
  616. Error err = da->make_dir(dest_dir + binary_name);
  617. if (err) {
  618. memdelete(da);
  619. return err;
  620. }
  621. }
  622. memdelete(da);
  623. }
  624. ep.step("Making .pck", 0);
  625. String pack_path = dest_dir + binary_name + ".pck";
  626. Vector<SharedObject> libraries;
  627. Error err = save_pack(p_preset, pack_path, &libraries);
  628. if (err)
  629. return err;
  630. ep.step("Extracting and configuring Xcode project", 1);
  631. String library_to_use = "libgodot.iphone." + String(p_debug ? "debug" : "release") + ".fat.a";
  632. print_line("static library: " + library_to_use);
  633. String pkg_name;
  634. if (p_preset->get("application/name") != "")
  635. pkg_name = p_preset->get("application/name"); // app_name
  636. else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "")
  637. pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
  638. else
  639. pkg_name = "Unnamed";
  640. bool found_library = false;
  641. int total_size = 0;
  642. const String project_file = "godot_ios.xcodeproj/project.pbxproj";
  643. Set<String> files_to_parse;
  644. files_to_parse.insert("godot_ios/godot_ios-Info.plist");
  645. files_to_parse.insert(project_file);
  646. files_to_parse.insert("godot_ios/export_options.plist");
  647. files_to_parse.insert("godot_ios/dummy.cpp");
  648. files_to_parse.insert("godot_ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata");
  649. files_to_parse.insert("godot_ios.xcodeproj/xcshareddata/xcschemes/godot_ios.xcscheme");
  650. IOSConfigData config_data = {
  651. pkg_name,
  652. binary_name,
  653. _get_additional_plist_content(),
  654. String(" ").join(_get_preset_architectures(p_preset)),
  655. _get_linker_flags(),
  656. _get_cpp_code()
  657. };
  658. DirAccess *tmp_app_path = DirAccess::create_for_path(dest_dir);
  659. ERR_FAIL_COND_V(!tmp_app_path, ERR_CANT_CREATE)
  660. print_line("Unzipping...");
  661. FileAccess *src_f = NULL;
  662. zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
  663. unzFile src_pkg_zip = unzOpen2(src_pkg_name.utf8().get_data(), &io);
  664. if (!src_pkg_zip) {
  665. EditorNode::add_io_error("Could not open export template (not a zip file?):\n" + src_pkg_name);
  666. return ERR_CANT_OPEN;
  667. }
  668. ERR_FAIL_COND_V(!src_pkg_zip, ERR_CANT_OPEN);
  669. int ret = unzGoToFirstFile(src_pkg_zip);
  670. Vector<uint8_t> project_file_data;
  671. while (ret == UNZ_OK) {
  672. bool is_execute = false;
  673. //get filename
  674. unz_file_info info;
  675. char fname[16384];
  676. ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, NULL, 0, NULL, 0);
  677. String file = fname;
  678. print_line("READ: " + file);
  679. Vector<uint8_t> data;
  680. data.resize(info.uncompressed_size);
  681. //read
  682. unzOpenCurrentFile(src_pkg_zip);
  683. unzReadCurrentFile(src_pkg_zip, data.ptrw(), data.size());
  684. unzCloseCurrentFile(src_pkg_zip);
  685. //write
  686. file = file.replace_first("iphone/", "");
  687. if (files_to_parse.has(file)) {
  688. print_line(String("parse ") + file);
  689. _fix_config_file(p_preset, data, config_data, p_debug);
  690. } else if (file.begins_with("libgodot.iphone")) {
  691. if (file != library_to_use) {
  692. ret = unzGoToNextFile(src_pkg_zip);
  693. continue; //ignore!
  694. }
  695. found_library = true;
  696. is_execute = true;
  697. file = "godot_ios.a";
  698. }
  699. if (file == project_file) {
  700. project_file_data = data;
  701. }
  702. ///@TODO need to parse logo files
  703. if (data.size() > 0) {
  704. file = file.replace("godot_ios", binary_name);
  705. print_line("ADDING: " + file + " size: " + itos(data.size()));
  706. total_size += data.size();
  707. /* write it into our folder structure */
  708. file = dest_dir + file;
  709. /* make sure this folder exists */
  710. String dir_name = file.get_base_dir();
  711. if (!tmp_app_path->dir_exists(dir_name)) {
  712. print_line("Creating " + dir_name);
  713. Error dir_err = tmp_app_path->make_dir_recursive(dir_name);
  714. if (dir_err) {
  715. ERR_PRINTS("Can't create '" + dir_name + "'.");
  716. unzClose(src_pkg_zip);
  717. memdelete(tmp_app_path);
  718. return ERR_CANT_CREATE;
  719. }
  720. }
  721. /* write the file */
  722. FileAccess *f = FileAccess::open(file, FileAccess::WRITE);
  723. if (!f) {
  724. ERR_PRINTS("Can't write '" + file + "'.");
  725. unzClose(src_pkg_zip);
  726. memdelete(tmp_app_path);
  727. return ERR_CANT_CREATE;
  728. };
  729. f->store_buffer(data.ptr(), data.size());
  730. f->close();
  731. memdelete(f);
  732. #ifdef OSX_ENABLED
  733. if (is_execute) {
  734. // we need execute rights on this file
  735. chmod(file.utf8().get_data(), 0755);
  736. }
  737. #endif
  738. }
  739. ret = unzGoToNextFile(src_pkg_zip);
  740. }
  741. /* we're done with our source zip */
  742. unzClose(src_pkg_zip);
  743. if (!found_library) {
  744. ERR_PRINTS("Requested template library '" + library_to_use + "' not found. It might be missing from your template archive.");
  745. memdelete(tmp_app_path);
  746. return ERR_FILE_NOT_FOUND;
  747. }
  748. String iconset_dir = dest_dir + binary_name + "/Images.xcassets/AppIcon.appiconset/";
  749. err = OK;
  750. if (!tmp_app_path->dir_exists(iconset_dir)) {
  751. err = tmp_app_path->make_dir_recursive(iconset_dir);
  752. }
  753. memdelete(tmp_app_path);
  754. if (err)
  755. return err;
  756. err = _export_icons(p_preset, iconset_dir);
  757. if (err)
  758. return err;
  759. err = _export_loading_screens(p_preset, dest_dir + binary_name + "/");
  760. if (err)
  761. return err;
  762. print_line("Exporting additional assets");
  763. Vector<IOSExportAsset> assets;
  764. _export_additional_assets(dest_dir + binary_name, libraries, assets);
  765. _add_assets_to_project(project_file_data, assets);
  766. String project_file_name = dest_dir + binary_name + ".xcodeproj/project.pbxproj";
  767. FileAccess *f = FileAccess::open(project_file_name, FileAccess::WRITE);
  768. if (!f) {
  769. ERR_PRINTS("Can't write '" + project_file_name + "'.");
  770. return ERR_CANT_CREATE;
  771. };
  772. f->store_buffer(project_file_data.ptr(), project_file_data.size());
  773. f->close();
  774. memdelete(f);
  775. #ifdef OSX_ENABLED
  776. ep.step("Code-signing dylibs", 2);
  777. DirAccess *dylibs_dir = DirAccess::open(dest_dir + binary_name + "/dylibs");
  778. ERR_FAIL_COND_V(!dylibs_dir, ERR_CANT_OPEN);
  779. CodesignData codesign_data(p_preset, p_debug);
  780. err = _walk_dir_recursive(dylibs_dir, _codesign, &codesign_data);
  781. memdelete(dylibs_dir);
  782. ERR_FAIL_COND_V(err, err);
  783. ep.step("Making .xcarchive", 3);
  784. String archive_path = p_path.get_basename() + ".xcarchive";
  785. List<String> archive_args;
  786. archive_args.push_back("-project");
  787. archive_args.push_back(dest_dir + binary_name + ".xcodeproj");
  788. archive_args.push_back("-scheme");
  789. archive_args.push_back(binary_name);
  790. archive_args.push_back("-sdk");
  791. archive_args.push_back("iphoneos");
  792. archive_args.push_back("-configuration");
  793. archive_args.push_back(p_debug ? "Debug" : "Release");
  794. archive_args.push_back("-destination");
  795. archive_args.push_back("generic/platform=iOS");
  796. archive_args.push_back("archive");
  797. archive_args.push_back("-archivePath");
  798. archive_args.push_back(archive_path);
  799. err = OS::get_singleton()->execute("xcodebuild", archive_args, true);
  800. ERR_FAIL_COND_V(err, err);
  801. ep.step("Making .ipa", 4);
  802. List<String> export_args;
  803. export_args.push_back("-exportArchive");
  804. export_args.push_back("-archivePath");
  805. export_args.push_back(archive_path);
  806. export_args.push_back("-exportOptionsPlist");
  807. export_args.push_back(dest_dir + binary_name + "/export_options.plist");
  808. export_args.push_back("-allowProvisioningUpdates");
  809. export_args.push_back("-exportPath");
  810. export_args.push_back(dest_dir);
  811. err = OS::get_singleton()->execute("xcodebuild", export_args, true);
  812. ERR_FAIL_COND_V(err, err);
  813. #else
  814. print_line(".ipa can only be built on macOS. Leaving Xcode project without building the package.");
  815. #endif
  816. return OK;
  817. }
  818. bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
  819. bool valid = true;
  820. String err;
  821. if (!exists_export_template("iphone.zip", &err)) {
  822. valid = false;
  823. }
  824. if (p_preset->get("custom_package/debug") != "" && !FileAccess::exists(p_preset->get("custom_package/debug"))) {
  825. valid = false;
  826. err += "Custom debug package not found.\n";
  827. }
  828. if (p_preset->get("custom_package/release") != "" && !FileAccess::exists(p_preset->get("custom_package/release"))) {
  829. valid = false;
  830. err += "Custom release package not found.\n";
  831. }
  832. if (!err.empty())
  833. r_error = err;
  834. r_missing_templates = !valid;
  835. return valid;
  836. }
  837. EditorExportPlatformIOS::EditorExportPlatformIOS() {
  838. Ref<Image> img = memnew(Image(_iphone_logo));
  839. logo.instance();
  840. logo->create_from_image(img);
  841. }
  842. EditorExportPlatformIOS::~EditorExportPlatformIOS() {
  843. }
  844. void register_iphone_exporter() {
  845. Ref<EditorExportPlatformIOS> platform;
  846. platform.instance();
  847. EditorExport::get_singleton()->add_export_platform(platform);
  848. }