Skip to content

Commit

Permalink
Merge pull request #1546 from andydotxyz/fix/1504
Browse files Browse the repository at this point in the history
Fix iOS app upload
  • Loading branch information
andydotxyz committed Nov 16, 2020
2 parents 20d79d9 + fc07a1c commit c186353
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ More detailed release notes can be found on the [releases page](https://github.c
* Entry copy/paste is crashing on android 7.1 (#1511)
* Fyne package creating invalid windows packages (#1521)
* Menu bar initially doesn't respond to mouse input on macOS (#505)
* iOS: Missing CFBundleIconName and asset catalog (#1504)
* CenterOnScreen causes crash on MacOS when called from goroutine (#1539)


Expand Down
55 changes: 45 additions & 10 deletions cmd/fyne/commands/package-mobile.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package commands

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"

"fyne.io/fyne"
"fyne.io/fyne/cmd/fyne/internal/mobile"
"fyne.io/fyne/cmd/fyne/internal/templates"
"fyne.io/fyne/cmd/fyne/internal/util"
"github.com/pkg/errors"
)

func (p *packager) packageAndroid(arch string) error {
Expand All @@ -18,22 +24,51 @@ func (p *packager) packageIOS() error {
return err
}

appDir := filepath.Join(p.dir, mobile.AppOutputName(p.os, p.name))
iconPath := filepath.Join(appDir, "Icon.png")
if err = util.CopyFile(p.icon, iconPath); err != nil {
return err
assetDir := util.EnsureSubDir(p.dir, "Images.xcassets")
defer os.RemoveAll(assetDir)
err = ioutil.WriteFile(filepath.Join(assetDir, "Contents.json"), []byte(`{
"info" : {
"author" : "xcode",
"version" : 1
}
}`), 0644)
if err != nil {
fyne.LogError("Content err", err)
}

if err = copyResizeIcon("120", appDir); err != nil {
iconDir := util.EnsureSubDir(assetDir, "AppIcon.appiconset")
contentFile, _ := os.Create(filepath.Join(iconDir, "Contents.json"))

err = templates.XCAssetsDarwin.Execute(contentFile, nil)
if err != nil {
return errors.Wrap(err, "Failed to write xcassets content template")
}

if err = copyResizeIcon(1024, iconDir, p.icon); err != nil {
return err
}
if err = copyResizeIcon("76", appDir); err != nil {
if err = copyResizeIcon(180, iconDir, p.icon); err != nil {
return err
}
if err = copyResizeIcon(120, iconDir, p.icon); err != nil {
return err
}
if err = copyResizeIcon(76, iconDir, p.icon); err != nil {
return err
}
if err = copyResizeIcon(152, iconDir, p.icon); err != nil {
return err
}
return copyResizeIcon("152", appDir)
}

func copyResizeIcon(size, dir string) error {
cmd := exec.Command("sips", "-o", dir+"/Icon_"+size+".png", "-Z", size, dir+"/Icon.png")
appDir := filepath.Join(p.dir, mobile.AppOutputName(p.os, p.name))
cmd := exec.Command("xcrun", "actool", "Images.xcassets", "--compile", appDir, "--platform",
"iphoneos", "--target-device", "iphone", "--minimum-deployment-target", "9.0", "--app-icon", "AppIcon",
"--output-partial-info-plist", "/dev/null")
return cmd.Run()
}

func copyResizeIcon(size int, dir, source string) error {
path := fmt.Sprintf("%s/Icon_%d.png", dir, size)
strSize := fmt.Sprintf("%d", size)
return exec.Command("sips", "-o", path, "-Z", strSize, source).Run()
}
34 changes: 24 additions & 10 deletions cmd/fyne/internal/mobile/build_iosapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,32 @@ var infoplistTmpl = template.Must(template.New("infoplist").Parse(`<?xml version
<key>CFBundleVersion</key>
<string>{{.Build}}</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Icon.png</string>
<string>Icon_76.png</string>
<string>Icon_152.png</string>
<string>Icon_120.png</string>
</array>
</dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon60x60</string>
</array>
<key>CFBundleIconName</key>
<string>AppIcon</string>
</dict>
</dict>
<key>CFBundleIcons~ipad</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon60x60</string>
<string>AppIcon76x76</string>
</array>
<key>CFBundleIconName</key>
<string>AppIcon</string>
</dict>
</dict>
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
4 changes: 3 additions & 1 deletion cmd/fyne/internal/mobile/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,16 @@ func envInit() (err error) {
// An arbitrary standard package ('runtime' here) is given to go-list.
// This is because go-list tries to analyze the module at the current directory if no packages are given,
// and if the module doesn't have any Go file, go-list fails. See golang/go#36668.

// TODO re-enable once we find out what broke after September event 2020
//cmd := exec.Command("go", "list", "-e", "-f", `{{range context.ReleaseTags}}{{if eq . "go1.14"}}{{.}}{{end}}{{end}}`, "runtime")
//cmd.Stderr = os.Stderr
//out, err := cmd.Output()
//if err != nil {
// return err
//}
//if len(strings.TrimSpace(string(out))) > 0 {
// bitcodeEnabled = true // TODO re-enable once we find out what broke after September event 2020
// bitcodeEnabled = true
//}

// Setup the cross-compiler environments.
Expand Down
5 changes: 5 additions & 0 deletions cmd/fyne/internal/templates/bundled.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ var resourceEntitlementsPlist = &fyne.StaticResource{
StaticName: "entitlements.plist",
StaticContent: []byte{
60, 63, 120, 109, 108, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 48, 34, 32, 101, 110, 99, 111, 100, 105, 110, 103, 61, 34, 85, 84, 70, 45, 56, 34, 63, 62, 10, 60, 33, 68, 79, 67, 84, 89, 80, 69, 32, 112, 108, 105, 115, 116, 32, 80, 85, 66, 76, 73, 67, 32, 34, 45, 47, 47, 65, 112, 112, 108, 101, 47, 47, 68, 84, 68, 32, 80, 76, 73, 83, 84, 32, 49, 46, 48, 47, 47, 69, 78, 34, 32, 34, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 97, 112, 112, 108, 101, 46, 99, 111, 109, 47, 68, 84, 68, 115, 47, 80, 114, 111, 112, 101, 114, 116, 121, 76, 105, 115, 116, 45, 49, 46, 48, 46, 100, 116, 100, 34, 62, 10, 60, 112, 108, 105, 115, 116, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 48, 34, 62, 10, 60, 100, 105, 99, 116, 62, 10, 32, 32, 32, 32, 60, 107, 101, 121, 62, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 45, 105, 100, 101, 110, 116, 105, 102, 105, 101, 114, 60, 47, 107, 101, 121, 62, 10, 32, 32, 32, 32, 60, 115, 116, 114, 105, 110, 103, 62, 123, 123, 46, 84, 101, 97, 109, 73, 68, 125, 125, 46, 123, 123, 46, 65, 112, 112, 73, 68, 125, 125, 60, 47, 115, 116, 114, 105, 110, 103, 62, 10, 60, 47, 100, 105, 99, 116, 62, 10, 60, 47, 112, 108, 105, 115, 116, 62}}

var resourceXcassetsJSON = &fyne.StaticResource{
StaticName: "xcassets.JSON",
StaticContent: []byte{
123, 10, 32, 32, 34, 105, 109, 97, 103, 101, 115, 34, 32, 58, 32, 91, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 104, 111, 110, 101, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 50, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 50, 48, 120, 50, 48, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 104, 111, 110, 101, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 51, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 50, 48, 120, 50, 48, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 104, 111, 110, 101, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 50, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 50, 57, 120, 50, 57, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 104, 111, 110, 101, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 51, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 50, 57, 120, 50, 57, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 104, 111, 110, 101, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 50, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 52, 48, 120, 52, 48, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 104, 111, 110, 101, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 51, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 52, 48, 120, 52, 48, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 102, 105, 108, 101, 110, 97, 109, 101, 34, 32, 58, 32, 34, 73, 99, 111, 110, 95, 49, 50, 48, 46, 112, 110, 103, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 104, 111, 110, 101, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 50, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 54, 48, 120, 54, 48, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 102, 105, 108, 101, 110, 97, 109, 101, 34, 32, 58, 32, 34, 73, 99, 111, 110, 95, 49, 56, 48, 46, 112, 110, 103, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 104, 111, 110, 101, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 51, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 54, 48, 120, 54, 48, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 97, 100, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 49, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 50, 48, 120, 50, 48, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 97, 100, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 50, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 50, 48, 120, 50, 48, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 97, 100, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 49, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 50, 57, 120, 50, 57, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 97, 100, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 50, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 50, 57, 120, 50, 57, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 97, 100, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 49, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 52, 48, 120, 52, 48, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 97, 100, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 50, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 52, 48, 120, 52, 48, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 102, 105, 108, 101, 110, 97, 109, 101, 34, 32, 58, 32, 34, 73, 99, 111, 110, 95, 55, 54, 46, 112, 110, 103, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 97, 100, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 49, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 55, 54, 120, 55, 54, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 102, 105, 108, 101, 110, 97, 109, 101, 34, 32, 58, 32, 34, 73, 99, 111, 110, 95, 49, 53, 50, 46, 112, 110, 103, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 97, 100, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 50, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 55, 54, 120, 55, 54, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 112, 97, 100, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 50, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 56, 51, 46, 53, 120, 56, 51, 46, 53, 34, 10, 32, 32, 32, 32, 125, 44, 10, 32, 32, 32, 32, 123, 10, 32, 32, 32, 32, 32, 32, 34, 102, 105, 108, 101, 110, 97, 109, 101, 34, 32, 58, 32, 34, 73, 99, 111, 110, 95, 49, 48, 50, 52, 46, 112, 110, 103, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 105, 100, 105, 111, 109, 34, 32, 58, 32, 34, 105, 111, 115, 45, 109, 97, 114, 107, 101, 116, 105, 110, 103, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 99, 97, 108, 101, 34, 32, 58, 32, 34, 49, 120, 34, 44, 10, 32, 32, 32, 32, 32, 32, 34, 115, 105, 122, 101, 34, 32, 58, 32, 34, 49, 48, 50, 52, 120, 49, 48, 50, 52, 34, 10, 32, 32, 32, 32, 125, 10, 32, 32, 93, 44, 10, 32, 32, 34, 105, 110, 102, 111, 34, 32, 58, 32, 123, 10, 32, 32, 32, 32, 34, 97, 117, 116, 104, 111, 114, 34, 32, 58, 32, 34, 120, 99, 111, 100, 101, 34, 44, 10, 32, 32, 32, 32, 34, 118, 101, 114, 115, 105, 111, 110, 34, 32, 58, 32, 49, 10, 32, 32, 125, 10, 125}}
103 changes: 103 additions & 0 deletions cmd/fyne/internal/templates/data/xcassets.JSON
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"filename" : "Icon_120.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"filename" : "Icon_180.png",
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"filename" : "Icon_76.png",
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"filename" : "Icon_152.png",
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"filename" : "Icon_1024.png",
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
3 changes: 3 additions & 0 deletions cmd/fyne/internal/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ var (

// InfoPlistDarwin is the manifest file for darwin packaging
InfoPlistDarwin = template.Must(template.New("Manifest").Parse(string(resourceInfoPlist.StaticContent)))

// XCAssetsDarwin is the Contents.json file for darwin xcassets bundle
XCAssetsDarwin = template.Must(template.New("XCAssets").Parse(string(resourceXcassetsJSON.StaticContent)))
)

0 comments on commit c186353

Please sign in to comment.