From ecaa397834eeac913d4148008d879115a6491457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 29 Jun 2026 15:39:14 +0800 Subject: [PATCH] release: Fix update apple version script --- cmd/internal/update_apple_version/main.go | 41 ++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/cmd/internal/update_apple_version/main.go b/cmd/internal/update_apple_version/main.go index 1b2d0db52..e6be84429 100644 --- a/cmd/internal/update_apple_version/main.go +++ b/cmd/internal/update_apple_version/main.go @@ -106,6 +106,7 @@ func findAndReplaceProjectVersion(objectsMap map[string]any, projectContent stri } func findObjectKey(objectsMap map[string]any, bundleIDList []string) []string { + globalSettings := collectBuildSettings(objectsMap) var objectKeyList []string for objectKey, object := range objectsMap { buildSettings := object.(map[string]any)["buildSettings"] @@ -116,13 +117,51 @@ func findObjectKey(objectsMap map[string]any, bundleIDList []string) []string { if bundleIDObject == nil { continue } - if common.Contains(bundleIDList, bundleIDObject.(string)) { + bundleID := expandBuildVariables(bundleIDObject.(string), globalSettings) + if common.Contains(bundleIDList, bundleID) { objectKeyList = append(objectKeyList, objectKey) } } return objectKeyList } +func collectBuildSettings(objectsMap map[string]any) map[string]string { + settings := make(map[string]string) + for _, object := range objectsMap { + buildSettings, loaded := object.(map[string]any)["buildSettings"].(map[string]any) + if !loaded { + continue + } + for key, value := range buildSettings { + valueString, isString := value.(string) + if !isString { + continue + } + settings[key] = valueString + } + } + return settings +} + +var buildVariableRegexp = regexp.MustCompile(`\$[({]([A-Za-z0-9_]+)[)}]`) + +func expandBuildVariables(value string, settings map[string]string) string { + for { + expanded := buildVariableRegexp.ReplaceAllStringFunc(value, func(match string) string { + name := buildVariableRegexp.FindStringSubmatch(match)[1] + replacement, loaded := settings[name] + if !loaded { + return match + } + return replacement + }) + if expanded == value { + return expanded + } + value = expanded + } +} + func findObjectKeyByDirectory(objectsMap map[string]any, directoryList []string) []string { var objectKeyList []string for objectKey, object := range objectsMap {