Skip to content

Commit

Permalink
Remove 32bit from iOS apps, Go 1.15 does not allow it
Browse files Browse the repository at this point in the history
Also this was stopped by Apple many years ago (iPhone 5s)
Fixes fyne-io#1497
  • Loading branch information
andydotxyz committed Nov 3, 2020
1 parent 4566b50 commit 7d6d04b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions cmd/fyne/internal/mobile/bind.go
Expand Up @@ -65,14 +65,14 @@ func writeFile(filename string, generate func(io.Writer) error) error {
return generate(f)
}

func packagesConfig(targetOS string) *packages.Config {
func packagesConfig(targetOS, targetArch string) *packages.Config {
config := &packages.Config{}
// Add CGO_ENABLED=1 explicitly since Cgo is disabled when GOOS is different from host OS.
config.Env = append(os.Environ(), "GOARCH=arm", "GOOS="+targetOS, "CGO_ENABLED=1")
config.Env = append(os.Environ(), "GOARCH="+targetArch, "GOOS="+targetOS, "CGO_ENABLED=1")
if targetOS == "android" {
// with Cgo enabled we need to ensure the C compiler is set via CC to
// avoid the error: "gcc: error: unrecognized command line option '-marm'"
config.Env = append(os.Environ(), androidEnv["arm"]...)
config.Env = append(os.Environ(), androidEnv[targetArch]...)
}
tags := buildTags
if targetOS == "darwin" {
Expand Down
12 changes: 6 additions & 6 deletions cmd/fyne/internal/mobile/build.go
Expand Up @@ -113,7 +113,7 @@ func runBuildImpl(cmd *command) (*packages.Package, error) {
cmd.usage()
os.Exit(1)
}
pkgs, err := packages.Load(packagesConfig(targetOS), buildPath)
pkgs, err := packages.Load(packagesConfig(targetOS, targetArchs[0]), buildPath)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -152,7 +152,7 @@ func runBuildImpl(cmd *command) (*packages.Package, error) {
return nil, fmt.Errorf("-os=ios requires XCode")
}
if buildRelease {
targetArchs = []string{"arm", "arm64"}
targetArchs = []string{"arm64"}
}

if pkg.Name != "main" {
Expand Down Expand Up @@ -381,8 +381,8 @@ func parseBuildTarget(buildTarget string) (os string, archs []string, _ error) {
}

// verify all archs are supported one while deduping.
isSupported := func(arch string) bool {
for _, a := range allArchs {
isSupported := func(os, arch string) bool {
for _, a := range allArchs[os] {
if a == arch {
return true
}
Expand All @@ -395,7 +395,7 @@ func parseBuildTarget(buildTarget string) (os string, archs []string, _ error) {
if _, ok := seen[arch]; ok {
continue
}
if !isSupported(arch) {
if !isSupported(os, arch) {
return "", nil, fmt.Errorf(`unsupported arch: %q`, arch)
}

Expand All @@ -408,7 +408,7 @@ func parseBuildTarget(buildTarget string) (os string, archs []string, _ error) {
targetOS = "darwin"
}
if all {
return targetOS, allArchs, nil
return targetOS, allArchs[os], nil
}
return targetOS, archs, nil
}
6 changes: 4 additions & 2 deletions cmd/fyne/internal/mobile/env.go
Expand Up @@ -23,7 +23,9 @@ var (

darwinArmNM string

allArchs = []string{"arm", "arm64", "386", "amd64"}
allArchs = map[string][]string{
"android": {"arm", "arm64", "386", "amd64"},
"ios": {"arm64", "amd64"}}

bitcodeEnabled bool
)
Expand Down Expand Up @@ -136,7 +138,7 @@ func envInit() (err error) {

darwinArmNM = "nm"
darwinEnv = make(map[string][]string)
for _, arch := range allArchs {
for _, arch := range allArchs["ios"] {
var env []string
var err error
var clang, cflags string
Expand Down

0 comments on commit 7d6d04b

Please sign in to comment.