From 9d176c1faedb5b9bda28a3e3dab0809129109f8b 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] 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 2782a467..69f47449 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 +}