Skip to content

Commit

Permalink
cmd/gomobile: add CFBundleShortVersionString and CFBundleVersion, fix…
Browse files Browse the repository at this point in the history
…ing 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: 1455c5e
GitHub-Pull-Request: #100
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/575115
Reviewed-by: Dmitri Shuralyov <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Dmitri Shuralyov <[email protected]>
Reviewed-by: Hajime Hoshi <[email protected]>
Reviewed-by: Than McIntosh <[email protected]>
  • Loading branch information
scosman authored and gopherbot committed Mar 29, 2024
1 parent 268e6c3 commit 365c353
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/gomobile/bind_iosapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"strconv"
"strings"
"text/template"
"time"

"golang.org/x/sync/errgroup"
"golang.org/x/tools/go/packages"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand All @@ -348,6 +352,10 @@ var infoFrameworkPlistTmpl = template.Must(template.New("infoFrameworkPlist").Pa
<string>{{.BundleID}}</string>
<key>MinimumOSVersion</key>
<string>100.0</string>
<key>CFBundleShortVersionString</key>
<string>{{.Version}}</string>
<key>CFBundleVersion</key>
<string>{{.Version}}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
</dict>
Expand Down

0 comments on commit 365c353

Please sign in to comment.