From 365c3533877076b351b0f5611a486ca6840d6864 Mon Sep 17 00:00:00 2001 From: scosman Date: Fri, 29 Mar 2024 00:30:25 +0000 Subject: [PATCH] cmd/gomobile: add CFBundleShortVersionString and CFBundleVersion, fixing Apple validation/distribution An app containing a framework can't be validated and distributed without these two entries in the framework bundle's `Info.plist`. Using `0.0.epoch` format per discussion here: https://go.dev/issue/66500#issuecomment-2025767017 Tested Xcode 15.3 with: - without keys, fails to validate - with keys: passing validation, distribution upload, and Apple's server validation ("Ready to test" server check). Fixes golang/go#66500 Change-Id: I2e0718247301ec7db36f8d85aea81b203ca7848b GitHub-Last-Rev: 1455c5e8165eecca82a5ab96d7d0c31b36607f7a GitHub-Pull-Request: golang/mobile#100 Reviewed-on: https://go-review.googlesource.com/c/mobile/+/575115 Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI Auto-Submit: Dmitri Shuralyov Reviewed-by: Hajime Hoshi Reviewed-by: Than McIntosh --- cmd/gomobile/bind_iosapp.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/gomobile/bind_iosapp.go b/cmd/gomobile/bind_iosapp.go index e8ebcc770..9a3e52169 100644 --- a/cmd/gomobile/bind_iosapp.go +++ b/cmd/gomobile/bind_iosapp.go @@ -15,6 +15,7 @@ import ( "strconv" "strings" "text/template" + "time" "golang.org/x/sync/errgroup" "golang.org/x/tools/go/packages" @@ -233,9 +234,11 @@ func goAppleBind(gobind string, pkgs []*packages.Package, targets []targetInfo) return err } err = writeFile(filepath.Join(frameworkInfoPlistDir, "Info.plist"), func(w io.Writer) error { + fmVersion := fmt.Sprintf("0.0.%d", time.Now().Unix()) infoFrameworkPlistlData := infoFrameworkPlistlData{ BundleID: escapePlistValue(rfc1034Label(title)), ExecutableName: escapePlistValue(title), + Version: escapePlistValue(fmVersion), } infoplist := new(bytes.Buffer) if err := infoFrameworkPlistTmpl.Execute(infoplist, infoFrameworkPlistlData); err != nil { @@ -333,6 +336,7 @@ func frameworkLayoutForTarget(t targetInfo, title string) (*frameworkLayout, err type infoFrameworkPlistlData struct { BundleID string ExecutableName string + Version string } // infoFrameworkPlistTmpl is a template for the Info.plist file in a framework. @@ -348,6 +352,10 @@ var infoFrameworkPlistTmpl = template.Must(template.New("infoFrameworkPlist").Pa {{.BundleID}} MinimumOSVersion 100.0 + CFBundleShortVersionString + {{.Version}} + CFBundleVersion + {{.Version}} CFBundlePackageType FMWK