From 1c0d0be62214ac75d565c26f117a89b84bb148ce Mon Sep 17 00:00:00 2001 From: SoY0ung <32095074+SoY0ung@users.noreply.github.com> Date: Sun, 14 May 2023 02:55:36 +0800 Subject: [PATCH 1/2] Fix 'The name for this app is invalid' error This error is related to App ID creation failure. App ID name must be an ascii text. It is not allowed to create an App ID with non-ascii text like Chinese, Japanese. If the name is NOT an ascii text, using bundleID instead. --- .../FetchProvisioningProfilesOperation.swift | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/AltStore/Operations/FetchProvisioningProfilesOperation.swift b/AltStore/Operations/FetchProvisioningProfilesOperation.swift index 2782a4675..69f474496 100644 --- a/AltStore/Operations/FetchProvisioningProfilesOperation.swift +++ b/AltStore/Operations/FetchProvisioningProfilesOperation.swift @@ -268,8 +268,17 @@ extension FetchProvisioningProfilesOperation } } } + //App ID name must be ascii. If the name is not ascii, using bundleID instead + let appIDName: String + if containsNonASCII(text: name) { + //Contains non ASCII (Such as Chinese/Japanese...), using bundleID + appIDName = bundleIdentifier + }else { + //ASCII text, keep going as usual + appIDName = name + } - ALTAppleAPI.shared.addAppID(withName: name, bundleIdentifier: bundleIdentifier, team: team, session: session) { (appID, error) in + ALTAppleAPI.shared.addAppID(withName: appIDName, bundleIdentifier: bundleIdentifier, team: team, session: session) { (appID, error) in do { do @@ -514,3 +523,13 @@ extension FetchProvisioningProfilesOperation } } } + +func containsNonASCII(text: String) -> Bool { + let ascii = CharacterSet(charactersIn: "\0"..."~") + for scalar in text.unicodeScalars { + if !ascii.contains(scalar) { + return true + } + } + return false +} From 84e2284f5691d58f0808723d071b49cb44fb348e Mon Sep 17 00:00:00 2001 From: SoY0ung <32095074+SoY0ung@users.noreply.github.com> Date: Sun, 14 May 2023 19:06:22 +0800 Subject: [PATCH 2/2] Optimizing function calls Thanks for @ktprograms advice --- .../FetchProvisioningProfilesOperation.swift | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/AltStore/Operations/FetchProvisioningProfilesOperation.swift b/AltStore/Operations/FetchProvisioningProfilesOperation.swift index 69f474496..896632265 100644 --- a/AltStore/Operations/FetchProvisioningProfilesOperation.swift +++ b/AltStore/Operations/FetchProvisioningProfilesOperation.swift @@ -270,7 +270,7 @@ extension FetchProvisioningProfilesOperation } //App ID name must be ascii. If the name is not ascii, using bundleID instead let appIDName: String - if containsNonASCII(text: name) { + if !name.allSatisfy({ $0.isASCII }) { //Contains non ASCII (Such as Chinese/Japanese...), using bundleID appIDName = bundleIdentifier }else { @@ -523,13 +523,3 @@ extension FetchProvisioningProfilesOperation } } } - -func containsNonASCII(text: String) -> Bool { - let ascii = CharacterSet(charactersIn: "\0"..."~") - for scalar in text.unicodeScalars { - if !ascii.contains(scalar) { - return true - } - } - return false -}