diff options
author | volzhs <volzhs@gmail.com> | 2018-12-05 05:51:00 +0900 |
---|---|---|
committer | volzhs <volzhs@gmail.com> | 2018-12-05 07:32:24 +0900 |
commit | e698a92b0911bb36b3c04869e462f146de3116fe (patch) | |
tree | 0c7263a69243010d71c2327574fae83daa23a5eb | |
parent | 9a8569d434107e721f5c7de0bf8ffe6471367d28 (diff) |
Add checking required field for exporting iOS
without specifying Identifier, it will cause `can not be parsed` error on Xcode
-rw-r--r-- | platform/iphone/export/export.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 7fb3afe9a9..8a9b254cdc 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -99,6 +99,70 @@ class EditorExportPlatformIOS : public EditorExportPlatform { Error _export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, Vector<IOSExportAsset> &r_exported_assets); Error _export_additional_assets(const String &p_out_dir, const Vector<SharedObject> &p_libraries, Vector<IOSExportAsset> &r_exported_assets); + bool is_package_name_valid(const String &p_package, String *r_error = NULL) const { + + String pname = p_package; + + if (pname.length() == 0) { + if (r_error) { + *r_error = "Identifier is missing."; + } + return false; + } + + int segments = 0; + bool first = true; + for (int i = 0; i < pname.length(); i++) { + CharType c = pname[i]; + if (first && c == '.') { + if (r_error) { + *r_error = "Identifier segments must be of non-zero length."; + } + return false; + } + if (c == '.') { + segments++; + first = true; + continue; + } + if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) { + if (r_error) { + *r_error = "The character '" + String::chr(c) + "' is not allowed in Identifier."; + } + return false; + } + if (first && (c >= '0' && c <= '9')) { + if (r_error) { + *r_error = "A digit cannot be the first character in a Identifier segment."; + } + return false; + } + if (first && c == '_') { + if (r_error) { + *r_error = "The character '" + String::chr(c) + "' cannot be the first character in a Identifier segment."; + } + return false; + } + first = false; + } + + if (segments == 0) { + if (r_error) { + *r_error = "The Identifier must have at least one '.' separator."; + } + return false; + } + + if (first) { + if (r_error) { + *r_error = "Identifier segments must be of non-zero length."; + } + return false; + } + + return true; + } + protected: virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features); virtual void get_export_options(List<ExportOption> *r_options); @@ -987,6 +1051,12 @@ bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset err += "App Store Team ID not specified - cannot configure the project.\n"; } + String identifier = p_preset->get("application/identifier"); + String pn_err; + if (!is_package_name_valid(identifier, &pn_err)) { + err += "Invalid Identifier - " + pn_err + "\n"; + } + for (unsigned int i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) { IconInfo info = icon_infos[i]; String icon_path = p_preset->get(info.preset_key); |