From cdb88a33acf2cfbf93fe1b2a6ee219c423ffbb58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 16 Aug 2026 00:25:05 +0800 Subject: [PATCH] Fix version quoting in Apple project update script --- cmd/internal/update_apple_version/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/internal/update_apple_version/main.go b/cmd/internal/update_apple_version/main.go index e6be8442..c365c051 100644 --- a/cmd/internal/update_apple_version/main.go +++ b/cmd/internal/update_apple_version/main.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/sagernet/sing-box/cmd/internal/build_shared" + "github.com/sagernet/sing-box/common/badversion" "github.com/sagernet/sing-box/log" "github.com/sagernet/sing/common" @@ -76,11 +77,20 @@ func findAndReplace(objectsMap map[string]any, projectContent string, bundleIDLi continue } updated = true - projectContent = projectContent[:versionStart] + "\"" + newVersion + "\"" + projectContent[versionEnd:] + projectContent = projectContent[:versionStart] + formatProjectVersion(newVersion) + projectContent[versionEnd:] } return projectContent, updated } +// Xcode serializes a version without quotes unless it contains a pre-release +// part; always quoting makes Xcode rewrite the value on the next save. +func formatProjectVersion(version string) string { + if badversion.Parse(version).PreReleaseIdentifier == "" { + return version + } + return "\"" + version + "\"" +} + func findAndReplaceProjectVersion(objectsMap map[string]any, projectContent string, directoryList []string, newVersion string) (string, bool) { objectKeyList := findObjectKeyByDirectory(objectsMap, directoryList) var updated bool