Gerrit Bot has uploaded this change for review.
Catalyst + macOS support
This pull request is a fork of [fork](https://github.com/waylybaye/gomobile) of a [fork](https://github.com/dpwiese/mobile).
It builds on #45 and #63 to add support for macOS (non-Catalyst), suitable for inclusion in a [binary Swift Package Manager package](https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages).
With these modifications I was able to build a rudimentary SPM package that exposes [QUIC](https://github.com/lucas-clemente/quic-go) to Swift and tests it with a Go server process. I’m happy to extract that into a separate repo if it’d be helpful.
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: fb6ffafc9ef9750948c306511e8572535c6dc318
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M go.mod
M go.sum
6 files changed, 267 insertions(+), 165 deletions(-)
diff --git a/cmd/gomobile/bind_iosapp.go b/cmd/gomobile/bind_iosapp.go
index 846a63f..76f0021 100644
--- a/cmd/gomobile/bind_iosapp.go
+++ b/cmd/gomobile/bind_iosapp.go
@@ -40,146 +40,190 @@
var name string
var title string
+ var buildTemp string
+
if buildO == "" {
name = pkgs[0].Name
title = strings.Title(name)
- buildO = title + ".framework"
+ buildO = title + ".xcframework"
} else {
- if !strings.HasSuffix(buildO, ".framework") {
- return fmt.Errorf("static framework name %q missing .framework suffix", buildO)
+ if !strings.HasSuffix(buildO, ".xcframework") {
+ return fmt.Errorf("static framework name %q missing .xcframework suffix", buildO)
}
base := filepath.Base(buildO)
- name = base[:len(base)-len(".framework")]
+ name = base[:len(base)-len(".xcframework")]
title = strings.Title(name)
}
-
- fileBases := make([]string, len(pkgs)+1)
- for i, pkg := range pkgs {
- fileBases[i] = bindPrefix + strings.Title(pkg.Name)
+ // Build static xcframework output directory.
+ if err := removeAll(buildO); err != nil {
+ return err
}
- fileBases[len(fileBases)-1] = "Universe"
-
- cmd = exec.Command("xcrun", "lipo", "-create")
modulesUsed, err := areGoModulesUsed()
if err != nil {
return err
}
- for _, arch := range archs {
- if err := writeGoMod("darwin", arch); err != nil {
- return err
- }
+ targets := allTargets("ios")
- env := darwinEnv[arch]
- // Add the generated packages to GOPATH for reverse bindings.
- gopath := fmt.Sprintf("GOPATH=%s%c%s", tmpdir, filepath.ListSeparator, goEnv("GOPATH"))
- env = append(env, gopath)
+ // create separate framework for ios,simulator and catalyst
+ // every target has at least one arch (arm64 and x86_64)
+ for _, target := range targets {
+ archs := allTargetArchs("ios", target)
- // Run `go mod tidy` to force to create go.sum.
- // Without go.sum, `go build` fails as of Go 1.16.
- if modulesUsed {
- if err := goModTidyAt(filepath.Join(tmpdir, "src"), env); err != nil {
+ for index, arch := range archs {
+ buildTemp = tmpdir + "/" + target + "/" + title + ".framework"
+
+ fileBases := make([]string, len(pkgs)+1)
+ for i, pkg := range pkgs {
+ fileBases[i] = bindPrefix + strings.Title(pkg.Name)
+ }
+ fileBases[len(fileBases)-1] = "Universe"
+
+ cmd = exec.Command("xcrun", "lipo", "-create")
+
+ env := darwinEnv[target+"_"+arch]
+
+ if err := writeGoMod("darwin", getenv(env, "GOARCH")); err != nil {
return err
}
- }
- path, err := goIOSBindArchive(name, env, filepath.Join(tmpdir, "src"))
- if err != nil {
- return fmt.Errorf("darwin-%s: %v", arch, err)
- }
- cmd.Args = append(cmd.Args, "-arch", archClang(arch), path)
- }
+ // Add the generated packages to GOPATH for reverse bindings.
+ gopath := fmt.Sprintf("GOPATH=%s%c%s", tmpdir, filepath.ListSeparator, goEnv("GOPATH"))
+ env = append(env, gopath)
+ fmt.Printf("[debug] goenv:\n%s\n", env)
- // Build static framework output directory.
- if err := removeAll(buildO); err != nil {
- return err
- }
- headers := buildO + "/Versions/A/Headers"
- if err := mkdir(headers); err != nil {
- return err
- }
- if err := symlink("A", buildO+"/Versions/Current"); err != nil {
- return err
- }
- if err := symlink("Versions/Current/Headers", buildO+"/Headers"); err != nil {
- return err
- }
- if err := symlink("Versions/Current/"+title, buildO+"/"+title); err != nil {
- return err
- }
+ // Run `go mod tidy` to force to create go.sum.
+ // Without go.sum, `go build` fails as of Go 1.16.
+ if modulesUsed {
+ if err := goModTidyAt(filepath.Join(tmpdir, "src"), env); err != nil {
+ return err
+ }
+ }
- cmd.Args = append(cmd.Args, "-o", buildO+"/Versions/A/"+title)
- if err := runCmd(cmd); err != nil {
- return err
- }
+ path, err := goIOSBindArchive(name, env, filepath.Join(tmpdir, "src"))
+ if err != nil {
+ return fmt.Errorf("darwin-%s: %v", arch, err)
+ }
- // Copy header file next to output archive.
- headerFiles := make([]string, len(fileBases))
- if len(fileBases) == 1 {
- headerFiles[0] = title + ".h"
- err := copyFile(
- headers+"/"+title+".h",
- srcDir+"/"+bindPrefix+title+".objc.h",
- )
- if err != nil {
- return err
- }
- } else {
- for i, fileBase := range fileBases {
- headerFiles[i] = fileBase + ".objc.h"
- err := copyFile(
- headers+"/"+fileBase+".objc.h",
- srcDir+"/"+fileBase+".objc.h")
+ if index > 0 {
+ // not the first static lib, attach to a fat library and skip create headers
+ fatCmd := exec.Command("xcrun", "lipo", "-create",
+ "-output", buildTemp+"/Versions/A/"+title,
+ buildTemp+"/Versions/A/"+title, path)
+
+ if err := runCmd(fatCmd); err != nil {
+ return err
+ }
+
+ continue
+ }
+
+ cmd.Args = append(cmd.Args, "-arch", archClang(arch), path)
+
+ headers := buildTemp + "/Versions/A/Headers"
+ if err := mkdir(headers); err != nil {
+ return err
+ }
+ if err := symlink("A", buildTemp+"/Versions/Current"); err != nil {
+ return err
+ }
+ if err := symlink("Versions/Current/Headers", buildTemp+"/Headers"); err != nil {
+ return err
+ }
+ if err := symlink("Versions/Current/"+title, buildTemp+"/"+title); err != nil {
+ return err
+ }
+
+ cmd.Args = append(cmd.Args, "-o", buildTemp+"/Versions/A/"+title)
+ if err := runCmd(cmd); err != nil {
+ return err
+ }
+
+ //Copy header file next to output archive.
+ headerFiles := make([]string, len(fileBases))
+ if len(fileBases) == 1 {
+ headerFiles[0] = title + ".h"
+ err := copyFile(
+ headers+"/"+title+".h",
+ srcDir+"/"+bindPrefix+title+".objc.h",
+ )
+ if err != nil {
+ return err
+ }
+ } else {
+ for i, fileBase := range fileBases {
+ headerFiles[i] = fileBase + ".objc.h"
+ err := copyFile(
+ headers+"/"+fileBase+".objc.h",
+ srcDir+"/"+fileBase+".objc.h")
+ if err != nil {
+ return err
+ }
+ }
+ err := copyFile(
+ headers+"/ref.h",
+ srcDir+"/ref.h")
+ if err != nil {
+ return err
+ }
+ headerFiles = append(headerFiles, title+".h")
+ err = writeFile(headers+"/"+title+".h", func(w io.Writer) error {
+ return iosBindHeaderTmpl.Execute(w, map[string]interface{}{
+ "pkgs": pkgs, "title": title, "bases": fileBases,
+ })
+ })
+ if err != nil {
+ return err
+ }
+ }
+
+ resources := buildTemp + "/Versions/A/Resources"
+ if err := mkdir(resources); err != nil {
+ return err
+ }
+ if err := symlink("Versions/Current/Resources", buildTemp+"/Resources"); err != nil {
+ return err
+ }
+ err = writeFile(buildTemp+"/Resources/Info.plist", func(w io.Writer) error {
+ _, err := w.Write([]byte(iosBindInfoPlist))
+ return err
+ })
+ if err != nil {
+ return err
+ }
+
+ var mmVals = struct {
+ Module string
+ Headers []string
+ }{
+ Module: title,
+ Headers: headerFiles,
+ }
+ err = writeFile(buildTemp+"/Versions/A/Modules/module.modulemap", func(w io.Writer) error {
+ return iosModuleMapTmpl.Execute(w, mmVals)
+ })
+ if err != nil {
+ return err
+ }
+ err = symlink("Versions/Current/Modules", buildTemp+"/Modules")
if err != nil {
return err
}
}
- err := copyFile(
- headers+"/ref.h",
- srcDir+"/ref.h")
- if err != nil {
- return err
- }
- headerFiles = append(headerFiles, title+".h")
- err = writeFile(headers+"/"+title+".h", func(w io.Writer) error {
- return iosBindHeaderTmpl.Execute(w, map[string]interface{}{
- "pkgs": pkgs, "title": title, "bases": fileBases,
- })
- })
- if err != nil {
- return err
- }
}
- resources := buildO + "/Versions/A/Resources"
- if err := mkdir(resources); err != nil {
- return err
- }
- if err := symlink("Versions/Current/Resources", buildO+"/Resources"); err != nil {
- return err
- }
- if err := writeFile(buildO+"/Resources/Info.plist", func(w io.Writer) error {
- _, err := w.Write([]byte(iosBindInfoPlist))
- return err
- }); err != nil {
- return err
+ // Finally combine ios/simulator/catalyst framework to xcframework
+ xcframeworkArgs := []string{"-create-xcframework"}
+
+ for _, target := range allTargets("ios") {
+ xcframeworkArgs = append(xcframeworkArgs, "-framework", tmpdir+"/"+target+"/"+title+".framework")
}
- var mmVals = struct {
- Module string
- Headers []string
- }{
- Module: title,
- Headers: headerFiles,
- }
- err = writeFile(buildO+"/Versions/A/Modules/module.modulemap", func(w io.Writer) error {
- return iosModuleMapTmpl.Execute(w, mmVals)
- })
- if err != nil {
- return err
- }
- return symlink("Versions/Current/Modules", buildO+"/Modules")
+ xcframeworkArgs = append(xcframeworkArgs, "-output", buildO)
+ cmd = exec.Command("xcodebuild", xcframeworkArgs...)
+ err = runCmd(cmd)
+ return err
}
const iosBindInfoPlist = `<?xml version="1.0" encoding="UTF-8"?>
diff --git a/cmd/gomobile/bind_test.go b/cmd/gomobile/bind_test.go
index 9a5ffa8..aee6587 100644
--- a/cmd/gomobile/bind_test.go
+++ b/cmd/gomobile/bind_test.go
@@ -112,7 +112,7 @@
}()
buildN = true
buildX = true
- buildO = "Asset.framework"
+ buildO = "Asset.xcframework"
buildTarget = "ios/arm64"
tests := []struct {
@@ -126,7 +126,7 @@
prefix: "Foo",
},
{
- out: "Abcde.framework",
+ out: "Abcde.xcframework",
},
}
for _, tc := range tests {
@@ -160,7 +160,7 @@
BitcodeEnabled bool
}{
outputData: output,
- Output: buildO[:len(buildO)-len(".framework")],
+ Output: buildO[:len(buildO)-len(".xcframework")],
Prefix: tc.prefix,
BitcodeEnabled: bitcodeEnabled,
}
@@ -195,26 +195,28 @@
var bindIOSTmpl = template.Must(template.New("output").Parse(`GOMOBILE={{.GOPATH}}/pkg/gomobile
WORK=$WORK
GOOS=darwin CGO_ENABLED=1 gobind -lang=go,objc -outdir=$WORK -tags=ios{{if .Prefix}} -prefix={{.Prefix}}{{end}} golang.org/x/mobile/asset
+rm -r -f "{{.Output}}.xcframework"
mkdir -p $WORK/src
-PWD=$WORK/src GOOS=darwin GOARCH=arm64 CC=iphoneos-clang CXX=iphoneos-clang++ CGO_CFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_CXXFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_LDFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_ENABLED=1 GOPATH=$WORK:$GOPATH go build -tags ios -x -buildmode=c-archive -o $WORK/{{.Output}}-arm64.a ./gobind
-rm -r -f "{{.Output}}.framework"
-mkdir -p {{.Output}}.framework/Versions/A/Headers
-ln -s A {{.Output}}.framework/Versions/Current
-ln -s Versions/Current/Headers {{.Output}}.framework/Headers
-ln -s Versions/Current/{{.Output}} {{.Output}}.framework/{{.Output}}
-xcrun lipo -create -arch arm64 $WORK/{{.Output}}-arm64.a -o {{.Output}}.framework/Versions/A/{{.Output}}
-cp $WORK/src/gobind/{{.Prefix}}Asset.objc.h {{.Output}}.framework/Versions/A/Headers/{{.Prefix}}Asset.objc.h
-mkdir -p {{.Output}}.framework/Versions/A/Headers
-cp $WORK/src/gobind/Universe.objc.h {{.Output}}.framework/Versions/A/Headers/Universe.objc.h
-mkdir -p {{.Output}}.framework/Versions/A/Headers
-cp $WORK/src/gobind/ref.h {{.Output}}.framework/Versions/A/Headers/ref.h
-mkdir -p {{.Output}}.framework/Versions/A/Headers
-mkdir -p {{.Output}}.framework/Versions/A/Headers
-mkdir -p {{.Output}}.framework/Versions/A/Resources
-ln -s Versions/Current/Resources {{.Output}}.framework/Resources
-mkdir -p {{.Output}}.framework/Resources
-mkdir -p {{.Output}}.framework/Versions/A/Modules
-ln -s Versions/Current/Modules {{.Output}}.framework/Modules
+PWD=$WORK/src GOOS=darwin GOARCH=arm64 CC=iphoneos-clang CXX=iphoneos-clang++ CGO_CFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_CXXFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_LDFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_ENABLED=1 ARCH=arm64 GOPATH=$WORK:$GOPATH go build -tags ios -x -buildmode=c-archive -o $WORK/{{.Output}}-arm64.a ./gobind
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Headers
+ln -s A $WORK/arm64/{{.Output}}.framework/Versions/Current
+ln -s Versions/Current/Headers $WORK/arm64/{{.Output}}.framework/Headers
+ln -s Versions/Current/{{.Output}} $WORK/arm64/{{.Output}}.framework/{{.Output}}
+xcrun lipo -create -arch arm64 $WORK/{{.Output}}-arm64.a -o $WORK/arm64/{{.Output}}.framework/Versions/A/{{.Output}}
+cp $WORK/src/gobind/{{.Prefix}}Asset.objc.h $WORK/arm64/{{.Output}}.framework/Versions/A/Headers/{{.Prefix}}Asset.objc.h
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Headers
+cp $WORK/src/gobind/Universe.objc.h $WORK/arm64/{{.Output}}.framework/Versions/A/Headers/Universe.objc.h
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Headers
+cp $WORK/src/gobind/ref.h $WORK/arm64/{{.Output}}.framework/Versions/A/Headers/ref.h
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Headers
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Headers
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Resources
+ln -s Versions/Current/Resources $WORK/arm64/{{.Output}}.framework/Resources
+mkdir -p $WORK/arm64/{{.Output}}.framework/Resources
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Modules
+ln -s Versions/Current/Modules $WORK/arm64/{{.Output}}.framework/Modules
+xcrun lipo $WORK/arm64/{{.Output}}.framework/Versions/A/{{.Output}} -thin arm64 -output $WORK/arm64/{{.Output}}.framework/Versions/A/{{.Output}}
+xcodebuild -create-xcframework -framework $WORK/arm64/{{.Output}}.framework -framework $WORK/amd64/{{.Output}}.framework -framework $WORK/catalyst/{{.Output}}.framework -output {{.Output}}.xcframework
`))
func TestBindIOSAll(t *testing.T) {
@@ -231,7 +233,7 @@
}()
buildN = true
buildX = true
- buildO = "Asset.framework"
+ buildO = "Asset.xcframework"
buildTarget = "ios"
buf := new(bytes.Buffer)
@@ -291,7 +293,7 @@
case "android":
out = filepath.Join(dir, "cgopkg.aar")
case "ios":
- out = filepath.Join(dir, "Cgopkg.framework")
+ out = filepath.Join(dir, "Cgopkg.xcframework")
}
tests := []struct {
diff --git a/cmd/gomobile/build.go b/cmd/gomobile/build.go
index 072af00..df81e73 100644
--- a/cmd/gomobile/build.go
+++ b/cmd/gomobile/build.go
@@ -290,6 +290,7 @@
func goCmdAt(at string, subcmd string, srcs []string, env []string, args ...string) error {
cmd := exec.Command("go", subcmd)
+ //cmd := exec.Command("go1.16rc1", subcmd)
tags := buildTags
targetOS, _, err := parseBuildTarget(buildTarget)
if err != nil {
diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
index 6dacc63..db47def 100644
--- a/cmd/gomobile/env.go
+++ b/cmd/gomobile/env.go
@@ -36,6 +36,35 @@
}
}
+func allTargets(targetOS string) []string {
+ switch targetOS {
+ case "ios":
+ return []string{"simulator", "ios", "catalyst", "macosx"}
+ default:
+ panic(fmt.Sprintf("unexpected target OS: %s", targetOS))
+ }
+}
+
+func allTargetArchs(targetOS string, target string) []string {
+ switch targetOS {
+ case "ios":
+ switch target {
+ case "simulator":
+ return []string{"arm64", "amd64"}
+ case "ios":
+ return []string{"arm64"}
+ case "catalyst":
+ return []string{"arm64", "amd64"}
+ case "macosx":
+ return []string{"arm64", "amd64"}
+ default:
+ panic(fmt.Sprintf("unexpected ios target: %s", target))
+ }
+ default:
+ panic(fmt.Sprintf("unexpected target OS: %s", targetOS))
+ }
+}
+
func buildEnvInit() (cleanup func(), err error) {
// Find gomobilepath.
gopath := goEnv("GOPATH")
@@ -141,38 +170,48 @@
darwinArmNM = "nm"
darwinEnv = make(map[string][]string)
- for _, arch := range allArchs("ios") {
- var env []string
- var err error
- var clang, cflags string
- switch arch {
- case "arm64":
- clang, cflags, err = envClang("iphoneos")
- cflags += " -miphoneos-version-min=" + buildIOSVersion
- case "amd64":
- clang, cflags, err = envClang("iphonesimulator")
- cflags += " -mios-simulator-version-min=" + buildIOSVersion
- default:
- panic(fmt.Errorf("unknown GOARCH: %q", arch))
- }
- if err != nil {
- return err
- }
+ for _, target := range allTargets("ios") {
+ for _, arch := range allTargetArchs("ios", target) {
+ var env []string
+ var err error
+ var clang, cflags string
+ switch target {
+ case "ios":
+ clang, cflags, err = envClang("iphoneos")
+ cflags += " -miphoneos-version-min=" + buildIOSVersion
+ case "simulator":
+ clang, cflags, err = envClang("iphonesimulator")
+ cflags += " -mios-simulator-version-min=" + buildIOSVersion
+ case "catalyst":
+ clang, cflags, err = envClang("macosx")
+ cflags += " -target x86_64-apple-ios13.0-macabi"
+ case "macosx":
+ clang, cflags, err = envClang("macosx")
+ // cflags += " -target x86_64-apple-ios13.0-macabi"
+ default:
+ panic(fmt.Errorf("unknown ios target: %q", arch))
+ }
- if bitcodeEnabled {
- cflags += " -fembed-bitcode"
+ if err != nil {
+ return err
+ }
+
+ if bitcodeEnabled {
+ cflags += " -fembed-bitcode"
+ }
+ env = append(env,
+ "GOOS=darwin",
+ "GOARCH="+arch,
+ "CC="+clang,
+ "CXX="+clang+"++",
+ "CGO_CFLAGS="+cflags+" -arch "+archClang(arch),
+ "CGO_CXXFLAGS="+cflags+" -arch "+archClang(arch),
+ "CGO_LDFLAGS="+cflags+" -arch "+archClang(arch),
+ "CGO_ENABLED=1",
+ "ARCH="+arch,
+ )
+ darwinEnv[target+"_"+arch] = env
}
- env = append(env,
- "GOOS=darwin",
- "GOARCH="+arch,
- "CC="+clang,
- "CXX="+clang+"++",
- "CGO_CFLAGS="+cflags+" -arch "+archClang(arch),
- "CGO_CXXFLAGS="+cflags+" -arch "+archClang(arch),
- "CGO_LDFLAGS="+cflags+" -arch "+archClang(arch),
- "CGO_ENABLED=1",
- )
- darwinEnv[arch] = env
}
return nil
diff --git a/go.mod b/go.mod
index 2a2408c..aadc1fc 100644
--- a/go.mod
+++ b/go.mod
@@ -5,6 +5,6 @@
require (
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
- golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd
- golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69
+ golang.org/x/mod v0.4.1
+ golang.org/x/tools v0.1.0
)
diff --git a/go.sum b/go.sum
index 1bf420b..418b84c 100644
--- a/go.sum
+++ b/go.sum
@@ -1,7 +1,9 @@
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
+github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 h1:estk1glOnSVeJ9tdEZZc5mAMDZk5lNJNyJ6DvrBkTEU=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
@@ -12,18 +14,32 @@
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd h1:ePuNC7PZ6O5BzgPn9bZayERXBdfZjUYoXEf5BTfDfh8=
golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY=
+golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k=
+golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69 h1:yBHHx+XZqXJBm6Exke3N7V9gnlsyXxoCPEb1yVenjfk=
golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
+golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #2 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of [fork](https://github.com/waylybaye/gomobile) of a [fork](https://github.com/dpwiese/mobile).
It builds on #45 and #63 to add support for macOS (non-Catalyst), suitable for inclusion in a [binary Swift Package Manager package](https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages).
With these modifications I was able to build a rudimentary SPM package that exposes [QUIC](https://github.com/lucas-clemente/quic-go) to Swift and tests it with a Go server process. I’m happy to extract that into a separate repo if it’d be helpful.
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: fb6ffafc9ef9750948c306511e8572535c6dc318
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M go.mod
M go.sum
6 files changed, 267 insertions(+), 165 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
1 comment:
Patchset:
Please resolve the merge conflict, thanks
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
File cmd/gomobile/env.go:
Patch Set #2, Line 188: case "macosx":
This seems a breaking change. Have we discussed and reached the agreement to change the target strings?
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #3 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of [fork](https://github.com/waylybaye/gomobile) of a [fork](https://github.com/dpwiese/mobile).
It builds on #45 and #63 to add support for macOS (non-Catalyst), suitable for inclusion in a [binary Swift Package Manager package](https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages).
With these modifications I was able to build a rudimentary SPM package that exposes [QUIC](https://github.com/lucas-clemente/quic-go) to Swift and tests it with a Go server process. I’m happy to extract that into a separate repo if it’d be helpful.
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: b678ba0b8987240d748db5b25e5c4d9b9e4d8670
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M go.sum
5 files changed, 250 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Patch set 3:Run-TryBot +1
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
1 comment:
File cmd/gomobile/env.go:
Patch Set #2, Line 188: case "macosx":
The current code builds for iOS simulator targeting amd64, and devices with arm64. […]
Ah sorry I misunderstood this switch is for |arch|.
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
3 comments:
Commit Message:
Patch Set #3, Line 9: This pull request is a fork of [fork](https://github.com/waylybaye/gomobile) of a [fork](https://github.com/dpwiese/mobile).
I think we should not use the markdown syntax here.
Patch Set #3, Line 11: It builds on #45 and #63 to add support for macOS (non-Catalyst), suitable for inclusion in a [binary Swift Package Manager package](https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages).
#45 and #63 don't make sense as a commit message. Please write a URL.
Do we have a filed issue for this change? If so, please write the issue number. If not, please file an issue. I'd like to understand what is the problem first.
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #4 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of [fork](https://github.com/waylybaye/gomobile) of a [fork](https://github.com/dpwiese/mobile).
It builds on #45 and #63 to add support for macOS (non-Catalyst), suitable for inclusion in a [binary Swift Package Manager package](https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages).
With these modifications I was able to build a rudimentary SPM package that exposes [QUIC](https://github.com/lucas-clemente/quic-go) to Swift and tests it with a Go server process. I’m happy to extract that into a separate repo if it’d be helpful.
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: df9f79bb1c1759d3a0dc8b181f1b46aee80b9b7f
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M go.sum
5 files changed, 255 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #5 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of a fork (https://github.com/waylybaye/gomobile) of a fork (https://github.com/dpwiese/mobile).
It builds on https://github.com/golang/mobile/pull/45 and https://github.com/golang/mobile/pull/63 to add support for macOS (non-Catalyst), suitable for inclusion in a binary Swift Package Manager package (https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages.
With these modifications I was able to build a rudimentary SPM package that exposes QUIC (https://github.com/lucas-clemente/quic-go) to Swift and tests it with a Go server process. I’m happy to extract that into a separate repo if it’d be helpful.
Fixes https://github.com/golang/go/issues/36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: df9f79bb1c1759d3a0dc8b181f1b46aee80b9b7f
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M go.sum
5 files changed, 255 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
3 comments:
Commit Message:
https://github. […]
Thanks, I'll take a look later.
I'm not familiar with Catalyst so probably I need someone's help...
Commit Message:
Patch Set #5, Line 15: Fixes https://github.com/golang/go/issues/36856
Fixes golang/go#36856
Please insert new line chars in this comment to fit with the width.
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
1 comment:
File cmd/gomobile/build.go:
Patch Set #5, Line 293: //cmd := exec.Command("go1.16rc1", subcmd)
Remove this.
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #6 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of a fork (https://github.com/waylybaye/gomobile)
of a fork (https://github.com/dpwiese/mobile).
It builds on two earlier PRs to add support for macOS (non-Catalyst), suitable
for inclusion in a binary Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
Based on earlier work:
- https://github.com/golang/mobile/pull/45
- https://github.com/golang/mobile/pull/63
With these modifications I was able to build a rudimentary SPM package that exposes
QUIC (https://github.com/lucas-clemente/quic-go) to Swift and tests it with a Go server.
I’m happy to extract that into a separate repo if it’d be helpful.
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: df9f79bb1c1759d3a0dc8b181f1b46aee80b9b7f
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M go.sum
5 files changed, 255 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #7 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of a fork (https://github.com/waylybaye/gomobile)
of a fork (https://github.com/dpwiese/mobile).
It builds on two earlier PRs to add support for macOS (non-Catalyst), suitable
for inclusion in a binary Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
Based on earlier work:
- https://github.com/golang/mobile/pull/45
- https://github.com/golang/mobile/pull/63
With these modifications I was able to build a rudimentary SPM package that exposes
QUIC (https://github.com/lucas-clemente/quic-go) to Swift and tests it with a Go server.
I’m happy to extract that into a separate repo if it’d be helpful.
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: 9d627d1b88ec1fa953810f2bed4a1fbb81c3d88f
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 254 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
4 comments:
Commit Message:
Please insert new line chars in this comment to fit with the width.
Sorry I didn't mention but the width is 72 chars.
File cmd/gomobile/bind_iosapp.go:
Patch Set #5, Line 71: for _, target := range targets {
```
for _, target := range allTargets("ios") {
```
Patch Set #5, Line 94: fmt.Printf("[debug] goenv:\n%s\n", env)
Is this a temporary log?
File cmd/gomobile/env.go:
Patch Set #7, Line 195: // cflags += " -target x86_64-apple-ios13.0-macabi"
Remove this.
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #8 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of a fork of a fork.
It builds on two earlier PRs to add support for macOS (non-Catalyst),
suitable for inclusion in a binary Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
Based on earlier work:
- https://github.com/golang/mobile/pull/45
- https://github.com/golang/mobile/pull/63
With these modifications I was able to build a rudimentary SPM package
that exposes QUIC (https://github.com/lucas-clemente/quic-go) to Swift
and tests it with a Go server. I’m happy to extract that into a separate
repo if it’d be helpful.
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: 9d627d1b88ec1fa953810f2bed4a1fbb81c3d88f
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 254 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #9 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of a fork of a fork.
It builds on two earlier PRs to add support for macOS (non-Catalyst),
suitable for inclusion in a binary Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
Based on earlier work:
- https://github.com/golang/mobile/pull/45
- https://github.com/golang/mobile/pull/63
With these modifications I was able to build a rudimentary SPM package
that exposes QUIC (https://github.com/lucas-clemente/quic-go) to Swift
and tests it with a Go server. I’m happy to extract that into a separate
repo if it’d be helpful.
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: 7db0e8867fd1885381d89869d0d00df0ed901efd
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 252 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
Gerrit Bot uploaded patch set #10 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of a fork of a fork.
It builds on two earlier PRs to add support for macOS (non-Catalyst),
suitable for inclusion in a binary Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
Based on earlier work:
- https://github.com/golang/mobile/pull/45
- https://github.com/golang/mobile/pull/63
With these modifications I was able to build a rudimentary SPM package
that exposes QUIC (https://github.com/lucas-clemente/quic-go) to Swift
and tests it with a Go server. I’m happy to extract that into a separate
repo if it’d be helpful.
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: abb78bd28e5e3f3459a2f30fa660e69868c90293
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 250 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
1 comment:
Patchset:
Addressed feedback. […]
I'll take a look later. Let me this unresolved. Thanks,
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
Patch set 10:Run-TryBot +1
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
3 comments:
Commit Message:
Patch Set #3, Line 9: This pull request is a fork of [fork](https://github.com/waylybaye/gomobile) of a [fork](https://github.com/dpwiese/mobile).
I think we should not use the markdown syntax here.
Sure, no problem.
Patch Set #3, Line 11: It builds on #45 and #63 to add support for macOS (non-Catalyst), suitable for inclusion in a [binary Swift Package Manager package](https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages).
#45 and #63 don't make sense as a commit message. Please write a URL.
Done.
Do we have a filed issue for this change? If so, please write the issue number. […]
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
7 comments:
Commit Message:
Patch Set #5, Line 15: Fixes https://github.com/golang/go/issues/36856
Fixes golang/go#36856
Done
Sorry I didn't mention but the width is 72 chars.
Done
Patchset:
Addressed feedback.
Question: running `go test ./...` in this repo always fails due to a module issue.
I’ve looked at https://github.com/golang/go/issues/27234 and it seems to be fixed
(thanks!) but it always fails with several errors of the form:
no exported names in the package "golang.org/x/mobile/bind/testdata/testpkg"
unable to import bind: [-: cannot find package "golang.org/x/mobile/bind" in any of:
It doesn’t check the module’s directory or seem to use modules at all. Is this correct?
File cmd/gomobile/bind_iosapp.go:
Patch Set #5, Line 71: for _, target := range targets {
``` […]
Done
Patch Set #5, Line 94: fmt.Printf("[debug] goenv:\n%s\n", env)
Is this a temporary log?
Done
File cmd/gomobile/build.go:
Patch Set #5, Line 293: //cmd := exec.Command("go1.16rc1", subcmd)
Remove this.
Done
File cmd/gomobile/env.go:
Patch Set #7, Line 195: // cflags += " -target x86_64-apple-ios13.0-macabi"
Remove this.
Done
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
3 comments:
Patchset:
Please resolve the merge conflict, thanks
Done!
Patchset:
Thanks for the review! I’ll probably need to rope in the author(s) of the original versions of this PR that I ultimately modified and submitted.
File cmd/gomobile/env.go:
Patch Set #2, Line 188: case "macosx":
This seems a breaking change. […]
The current code builds for iOS simulator targeting amd64, and devices with arm64.
How would this be a breaking change by adding targets instead of archs?
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
3 comments:
File cmd/gomobile/env.go:
Patch Set #10, Line 39: func allTargets(targetOS string) []string {
As this is defined only for iOS, what about defining a variable like
```
var iOSTargets = []string{"simulator", "ios", "catalyst", "macosx"}
```
?
Also please leave a comment.
Patch Set #10, Line 42: return []string{"simulator", "ios", "catalyst", "macosx"}
I slightly prefer 'macos' to 'macosx'. This string is not directly passed to clang as SDK, right?
Patch Set #10, Line 48: func allTargetArchs(targetOS string, target string) []string {
As this is defined only for iOS, what about removing |targetOS| argument and renaming this to `iOSTargetArchs`?
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #11 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of a fork of a fork.
It builds on two earlier PRs to add support for macOS (non-Catalyst),
suitable for inclusion in a binary Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
Based on earlier work:
- https://github.com/golang/mobile/pull/45
- https://github.com/golang/mobile/pull/63
With these modifications I was able to build a rudimentary SPM package
that exposes QUIC (https://github.com/lucas-clemente/quic-go) to Swift
and tests it with a Go server. I’m happy to extract that into a separate
repo if it’d be helpful.
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: 9d00df1fb790d2b6c1e324be3d9c19ef41e96c87
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 236 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig, Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #12 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of a fork of a fork.
It builds on two earlier PRs to add support for macOS (non-Catalyst),
suitable for inclusion in a binary Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
Based on earlier work:
- https://github.com/golang/mobile/pull/45
- https://github.com/golang/mobile/pull/63
With these modifications I was able to build a rudimentary SPM package
that exposes QUIC (https://github.com/lucas-clemente/quic-go) to Swift
and tests it with a Go server. I’m happy to extract that into a separate
repo if it’d be helpful.
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: cdc07c0698e4e4c76409efb0c66a3a6f2856f394
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 237 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
4 comments:
Patchset:
Thanks for the review!
File cmd/gomobile/env.go:
Patch Set #10, Line 39: func allTargets(targetOS string) []string {
As this is defined only for iOS, what about defining a variable like […]
Done
Patch Set #10, Line 42: return []string{"simulator", "ios", "catalyst", "macosx"}
I slightly prefer 'macos' to 'macosx'. […]
Correct, good point.
Patch Set #10, Line 48: func allTargetArchs(targetOS string, target string) []string {
As this is defined only for iOS, what about removing |targetOS| argument and renaming this to `iOSTa […]
Done
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
Gerrit Bot uploaded patch set #13 to this change.
mobile: support macOS and Catalyst
This pull request is a fork of a fork of a fork.
It builds on two earlier PRs to add support for macOS (non-Catalyst),
suitable for inclusion in a binary Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
Based on earlier work:
- https://github.com/golang/mobile/pull/45
- https://github.com/golang/mobile/pull/63
With these modifications I was able to build a rudimentary SPM package
that exposes QUIC (https://github.com/lucas-clemente/quic-go) to Swift
and tests it with a Go server. I’m happy to extract that into a separate
repo if it’d be helpful.
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: ab263e4123aad50e0c80148fb8ce944c1b0e2d67
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 240 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
6 comments:
Commit Message:
Patch Set #13, Line 7: mobile: support macOS and Catalyst
cmd/gomobile: support macOS and Catalyst
Patch Set #13, Line 9: This pull request is a fork of a fork of a fork.
We don't need this line as a commit message.
Please add an explanation what this change does. My understanding is that this change changes the output from .framework to .xcframework which can include multiple .frameworks for various targets. Is that correct?
Patch Set #13, Line 21: and tests it with a Go server. I’m happy to extract that into a separate
We don't need the last sentence "I'm happy..." as a commit message.
Patchset:
Thanks, the change seems pretty good!
File cmd/gomobile/env.go:
Patch Set #13, Line 39: // gomobile's "ios" target OS actually builds for multiple Apple platforms:
Please follow the Go's comment convention. Start with, e.g., "iOSTargets is ..."
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #14 to this change.
mobile: support macOS and Catalyst
Add support for macOS (non-Catalyst) and Catalyst targets.
The compiled library is packaged into a "fat" XCFramework file (as
opposed to a Framework), which includes binaries for iOS, macOS,
MacCatalyst (iOS on macOS), and iOS Simulator targets, for amd64 and
arm64 architectures.
The generated XCFramework file is suitable for distribution as a binary
Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
This change is based on earlier work:
https://github.com/golang/mobile/pull/45
https://github.com/golang/mobile/pull/63
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: ab263e4123aad50e0c80148fb8ce944c1b0e2d67
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 240 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
5 comments:
Commit Message:
Patch Set #13, Line 7: mobile: support macOS and Catalyst
cmd/gomobile: support macOS and Catalyst
Done
Patch Set #13, Line 9: This pull request is a fork of a fork of a fork.
We don't need this line as a commit message.
Done
Please add an explanation what this change does. […]
Done
Patch Set #13, Line 21: and tests it with a Go server. I’m happy to extract that into a separate
We don't need the last sentence "I'm happy..." as a commit message.
Done
File cmd/gomobile/env.go:
Patch Set #13, Line 39: // gomobile's "ios" target OS actually builds for multiple Apple platforms:
Please follow the Go's comment convention. Start with, e.g., "iOSTargets is ..." […]
Done
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
Gerrit Bot uploaded patch set #15 to this change.
cmd/gomobile: support macOS and Catalyst
Add support for macOS (non-Catalyst) and Catalyst targets.
The compiled library is packaged into a "fat" XCFramework file (as
opposed to a Framework), which includes binaries for iOS, macOS,
MacCatalyst (iOS on macOS), and iOS Simulator targets, for amd64 and
arm64 architectures.
The generated XCFramework file is suitable for distribution as a binary
Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
This change is based on earlier work:
https://github.com/golang/mobile/pull/45
https://github.com/golang/mobile/pull/63
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: 50f941d1f5dd056d4e435b62ef67368908905af9
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 241 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
1 comment:
File cmd/gomobile/env.go:
Patch Set #15, Line 208: "ARCH="+arch,
Is this environment (ARCH) variable necessary?
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
1 comment:
File cmd/gomobile/env.go:
Patch Set #15, Line 208: "ARCH="+arch,
Is this environment (ARCH) variable necessary?
Good question. I’ll take a look in the morning.
I’ll put together an example that ties everything together (gomobile, QUIC, Swift Package Manager). Thanks for your reviews today!
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
2 comments:
Patchset:
I built a small example demonstrating how this CL works:
File cmd/gomobile/env.go:
Patch Set #15, Line 208: "ARCH="+arch,
Good question. I’ll take a look in the morning. […]
Looks like ARCH isn’t necessary. Removed.
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
Gerrit Bot uploaded patch set #16 to this change.
cmd/gomobile: support macOS and Catalyst
Add support for macOS (non-Catalyst) and Catalyst targets.
The compiled library is packaged into a "fat" XCFramework file (as
opposed to a Framework), which includes binaries for iOS, macOS,
MacCatalyst (iOS on macOS), and iOS Simulator targets, for amd64 and
arm64 architectures.
The generated XCFramework file is suitable for distribution as a binary
Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
This change is based on earlier work:
https://github.com/golang/mobile/pull/45
https://github.com/golang/mobile/pull/63
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: 8a0a1e6ad613297c6e423595e5df28ac1b7eb002
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 240 insertions(+), 163 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
1 comment:
File cmd/gomobile/bind_test.go:
Patch Set #16, Line 200: PWD=$WORK/src GOOS=darwin GOARCH=arm64 CC=iphoneos-clang CXX=iphoneos-clang++ CGO_CFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_CXXFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_LDFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_ENABLED=1 ARCH=arm64 GOPATH=$WORK:$GOPATH go build -tags ios -x -buildmode=c-archive -o $WORK/{{.Output}}-arm64.a ./gobind
Remove `ARCH=arm64`
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #17 to this change.
cmd/gomobile: support macOS and Catalyst
Add support for macOS (non-Catalyst) and Catalyst targets.
The compiled library is packaged into a "fat" XCFramework file (as
opposed to a Framework), which includes binaries for iOS, macOS,
MacCatalyst (iOS on macOS), and iOS Simulator targets, for amd64 and
arm64 architectures.
The generated XCFramework file is suitable for distribution as a binary
Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
This change is based on earlier work:
https://github.com/golang/mobile/pull/45
https://github.com/golang/mobile/pull/63
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: 221210c78f088335396b64c194c1334ae97ca56c
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
M go.sum
4 files changed, 239 insertions(+), 162 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Patch set 17:Run-TryBot +1
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
1 comment:
File cmd/gomobile/bind_test.go:
Patch Set #16, Line 200: PWD=$WORK/src GOOS=darwin GOARCH=arm64 CC=iphoneos-clang CXX=iphoneos-clang++ CGO_CFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_CXXFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_LDFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_ENABLED=1 ARCH=arm64 GOPATH=$WORK:$GOPATH go build -tags ios -x -buildmode=c-archive -o $WORK/{{.Output}}-arm64.a ./gobind
Remove `ARCH=arm64`
Done
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Patch set 17:Code-Review +1
1 comment:
Patchset:
LGTM. Please wait for Hana's review. Thanks,
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
6 comments:
File cmd/gomobile/bind_iosapp.go:
Patch Set #17, Line 57: // Build static xcframework output directory.
let's remove this comment - the actual build is further down so it's confusing
Patch Set #17, Line 71: buildTemp
buildTemp := ... in the outer loop
(no need for reuse)
Patch Set #17, Line 79: cmd = exec.Command("xcrun", "lipo", "-create")
Can we define a new cmd instead of reusing this var, and move this next to where it is used first in the block? (line 117)
Patch Set #17, Line 107: buildTemp+"/Versions/A/"+title
How about defining a var to point buildTemp+"/Versions/A/"+title in the outer loop, and use that variable here and in the lipo inputfile list?
Patch Set #17, Line 138: //Copy header file next to output archive.
space
File go.sum:
Patch Set #17, Line 6: golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
what triggered this change?
`go mod tidy` still leaves this?
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Gerrit Bot uploaded patch set #18 to this change.
cmd/gomobile: support macOS and Catalyst
Add support for macOS (non-Catalyst) and Catalyst targets.
The compiled library is packaged into a "fat" XCFramework file (as
opposed to a Framework), which includes binaries for iOS, macOS,
MacCatalyst (iOS on macOS), and iOS Simulator targets, for amd64 and
arm64 architectures.
The generated XCFramework file is suitable for distribution as a binary
Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
This change is based on earlier work:
https://github.com/golang/mobile/pull/45
https://github.com/golang/mobile/pull/63
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: 623f8f38653c856d2cd07e721f0932e515b50d02
GitHub-Pull-Request: golang/mobile#65
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
3 files changed, 240 insertions(+), 161 deletions(-)
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
7 comments:
Patchset:
Thanks! Implemented your suggestions.
BTW, I’ve never been able to get the gobind tests (in particular TestGenGoObjcWrappers) to pass locally on my machine (currently macOS 12, Xcode 13 beta 2), either this branch or on master. Somewhere in clang it fails to find certain headers, like sys/types.h or stdarg.h (if you give it more -I args). Is this a known issue?
File cmd/gomobile/bind_iosapp.go:
Patch Set #17, Line 57: // Build static xcframework output directory.
let's remove this comment - the actual build is further down so it's confusing
Done
Patch Set #17, Line 71: buildTemp
buildTemp := ... in the outer loop […]
Done
Patch Set #17, Line 79: cmd = exec.Command("xcrun", "lipo", "-create")
Can we define a new cmd instead of reusing this var, and move this next to where it is used first in […]
Done
Patch Set #17, Line 107: buildTemp+"/Versions/A/"+title
How about defining a var to point buildTemp+"/Versions/A/"+title in the outer loop, and use that var […]
Good point. I also switched out the string concatenation for filepath.Join.
Patch Set #17, Line 138: //Copy header file next to output archive.
space
Done
File go.sum:
Patch Set #17, Line 6: golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
what triggered this change? […]
Done
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Randy Reddig.
Patch set 18:Run-TryBot +1Code-Review +2Trust +1
1 comment:
Patchset:
Thanks! Implemented your suggestions. […]
Can you file an issue and share the failure log?
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
Patchset:
Can you file an issue and share the failure log?
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Patch set 18:Code-Review +1Trust +1
Hajime Hoshi submitted this change.
cmd/gomobile: support macOS and Catalyst
Add support for macOS (non-Catalyst) and Catalyst targets.
The compiled library is packaged into a "fat" XCFramework file (as
opposed to a Framework), which includes binaries for iOS, macOS,
MacCatalyst (iOS on macOS), and iOS Simulator targets, for amd64 and
arm64 architectures.
The generated XCFramework file is suitable for distribution as a binary
Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages
This change is based on earlier work:
https://github.com/golang/mobile/pull/45
https://github.com/golang/mobile/pull/63
Fixes golang/go#36856
Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: 623f8f38653c856d2cd07e721f0932e515b50d02
GitHub-Pull-Request: golang/mobile#65
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/310949
Reviewed-by: Hyang-Ah Hana Kim <hya...@gmail.com>
Reviewed-by: Hajime Hoshi <hajim...@gmail.com>
Trust: Hyang-Ah Hana Kim <hya...@gmail.com>
Trust: Hajime Hoshi <hajim...@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hya...@gmail.com>
TryBot-Result: Go Bot <go...@golang.org>
---
M cmd/gomobile/bind_iosapp.go
M cmd/gomobile/bind_test.go
M cmd/gomobile/env.go
3 files changed, 240 insertions(+), 161 deletions(-)
diff --git a/cmd/gomobile/bind_iosapp.go b/cmd/gomobile/bind_iosapp.go
index 846a63f..83d9e3f 100644
--- a/cmd/gomobile/bind_iosapp.go
+++ b/cmd/gomobile/bind_iosapp.go
@@ -40,146 +40,188 @@
var name string
var title string
+
if buildO == "" {
name = pkgs[0].Name
title = strings.Title(name)
- buildO = title + ".framework"
+ buildO = title + ".xcframework"
} else {
- if !strings.HasSuffix(buildO, ".framework") {
- return fmt.Errorf("static framework name %q missing .framework suffix", buildO)
+ if !strings.HasSuffix(buildO, ".xcframework") {
+ return fmt.Errorf("static framework name %q missing .xcframework suffix", buildO)
}
base := filepath.Base(buildO)
- name = base[:len(base)-len(".framework")]
+ name = base[:len(base)-len(".xcframework")]
title = strings.Title(name)
}
- fileBases := make([]string, len(pkgs)+1)
- for i, pkg := range pkgs {
- fileBases[i] = bindPrefix + strings.Title(pkg.Name)
+ if err := removeAll(buildO); err != nil {
+ return err
}
- fileBases[len(fileBases)-1] = "Universe"
-
- cmd = exec.Command("xcrun", "lipo", "-create")
modulesUsed, err := areGoModulesUsed()
if err != nil {
return err
}
- for _, arch := range archs {
- if err := writeGoMod("darwin", arch); err != nil {
- return err
- }
+ // create separate framework for ios,simulator and catalyst
+ // every target has at least one arch (arm64 and x86_64)
+ var frameworkDirs []string
+ for _, target := range iOSTargets {
+ frameworkDir := filepath.Join(tmpdir, target, title+".framework")
+ frameworkDirs = append(frameworkDirs, frameworkDir)
- env := darwinEnv[arch]
- // Add the generated packages to GOPATH for reverse bindings.
- gopath := fmt.Sprintf("GOPATH=%s%c%s", tmpdir, filepath.ListSeparator, goEnv("GOPATH"))
- env = append(env, gopath)
+ for index, arch := range iOSTargetArchs(target) {
+ fileBases := make([]string, len(pkgs)+1)
+ for i, pkg := range pkgs {
+ fileBases[i] = bindPrefix + strings.Title(pkg.Name)
+ }
+ fileBases[len(fileBases)-1] = "Universe"
- // Run `go mod tidy` to force to create go.sum.
- // Without go.sum, `go build` fails as of Go 1.16.
- if modulesUsed {
- if err := goModTidyAt(filepath.Join(tmpdir, "src"), env); err != nil {
+ env := darwinEnv[target+"_"+arch]
+
+ if err := writeGoMod("darwin", getenv(env, "GOARCH")); err != nil {
return err
}
- }
- path, err := goIOSBindArchive(name, env, filepath.Join(tmpdir, "src"))
- if err != nil {
- return fmt.Errorf("darwin-%s: %v", arch, err)
- }
- cmd.Args = append(cmd.Args, "-arch", archClang(arch), path)
- }
+ // Add the generated packages to GOPATH for reverse bindings.
+ gopath := fmt.Sprintf("GOPATH=%s%c%s", tmpdir, filepath.ListSeparator, goEnv("GOPATH"))
+ env = append(env, gopath)
- // Build static framework output directory.
- if err := removeAll(buildO); err != nil {
- return err
- }
- headers := buildO + "/Versions/A/Headers"
- if err := mkdir(headers); err != nil {
- return err
- }
- if err := symlink("A", buildO+"/Versions/Current"); err != nil {
- return err
- }
- if err := symlink("Versions/Current/Headers", buildO+"/Headers"); err != nil {
- return err
- }
- if err := symlink("Versions/Current/"+title, buildO+"/"+title); err != nil {
- return err
- }
+ // Run `go mod tidy` to force to create go.sum.
+ // Without go.sum, `go build` fails as of Go 1.16.
+ if modulesUsed {
+ if err := goModTidyAt(filepath.Join(tmpdir, "src"), env); err != nil {
+ return err
+ }
+ }
- cmd.Args = append(cmd.Args, "-o", buildO+"/Versions/A/"+title)
- if err := runCmd(cmd); err != nil {
- return err
- }
+ path, err := goIOSBindArchive(name, env, filepath.Join(tmpdir, "src"))
+ if err != nil {
+ return fmt.Errorf("darwin-%s: %v", arch, err)
+ }
- // Copy header file next to output archive.
- headerFiles := make([]string, len(fileBases))
- if len(fileBases) == 1 {
- headerFiles[0] = title + ".h"
- err := copyFile(
- headers+"/"+title+".h",
- srcDir+"/"+bindPrefix+title+".objc.h",
- )
- if err != nil {
- return err
- }
- } else {
- for i, fileBase := range fileBases {
- headerFiles[i] = fileBase + ".objc.h"
- err := copyFile(
- headers+"/"+fileBase+".objc.h",
- srcDir+"/"+fileBase+".objc.h")
+ versionsDir := filepath.Join(frameworkDir, "Versions")
+ versionsADir := filepath.Join(versionsDir, "A")
+ titlePath := filepath.Join(versionsADir, title)
+ if index > 0 {
+ // not the first static lib, attach to a fat library and skip create headers
+ fatCmd := exec.Command(
+ "xcrun",
+ "lipo", "-create", "-output", titlePath, titlePath, path,
+ )
+ if err := runCmd(fatCmd); err != nil {
+ return err
+ }
+ continue
+ }
+
+ versionsAHeadersDir := filepath.Join(versionsADir, "Headers")
+ if err := mkdir(versionsAHeadersDir); err != nil {
+ return err
+ }
+ if err := symlink("A", filepath.Join(versionsDir, "Current")); err != nil {
+ return err
+ }
+ if err := symlink("Versions/Current/Headers", filepath.Join(frameworkDir, "Headers")); err != nil {
+ return err
+ }
+ if err := symlink(filepath.Join("Versions/Current", title), filepath.Join(frameworkDir, title)); err != nil {
+ return err
+ }
+
+ lipoCmd := exec.Command(
+ "xcrun",
+ "lipo", "-create", "-arch", archClang(arch), path, "-o", titlePath,
+ )
+ if err := runCmd(lipoCmd); err != nil {
+ return err
+ }
+
+ // Copy header file next to output archive.
+ var headerFiles []string
+ if len(fileBases) == 1 {
+ headerFiles = append(headerFiles, title+".h")
+ err := copyFile(
+ filepath.Join(versionsAHeadersDir, title+".h"),
+ filepath.Join(srcDir, bindPrefix+title+".objc.h"),
+ )
+ if err != nil {
+ return err
+ }
+ } else {
+ for _, fileBase := range fileBases {
+ headerFiles = append(headerFiles, fileBase+".objc.h")
+ err := copyFile(
+ filepath.Join(versionsAHeadersDir, fileBase+".objc.h"),
+ filepath.Join(srcDir, fileBase+".objc.h"),
+ )
+ if err != nil {
+ return err
+ }
+ }
+ err := copyFile(
+ filepath.Join(versionsAHeadersDir, "ref.h"),
+ filepath.Join(srcDir, "ref.h"),
+ )
+ if err != nil {
+ return err
+ }
+ headerFiles = append(headerFiles, title+".h")
+ err = writeFile(filepath.Join(versionsAHeadersDir, title+".h"), func(w io.Writer) error {
+ return iosBindHeaderTmpl.Execute(w, map[string]interface{}{
+ "pkgs": pkgs, "title": title, "bases": fileBases,
+ })
+ })
+ if err != nil {
+ return err
+ }
+ }
+
+ if err := mkdir(filepath.Join(versionsADir, "Resources")); err != nil {
+ return err
+ }
+ if err := symlink("Versions/Current/Resources", filepath.Join(frameworkDir, "Resources")); err != nil {
+ return err
+ }
+ err = writeFile(filepath.Join(frameworkDir, "Resources", "Info.plist"), func(w io.Writer) error {
+ _, err := w.Write([]byte(iosBindInfoPlist))
+ return err
+ })
+ if err != nil {
+ return err
+ }
+
+ var mmVals = struct {
+ Module string
+ Headers []string
+ }{
+ Module: title,
+ Headers: headerFiles,
+ }
+ err = writeFile(filepath.Join(versionsADir, "Modules", "module.modulemap"), func(w io.Writer) error {
+ return iosModuleMapTmpl.Execute(w, mmVals)
+ })
+ if err != nil {
+ return err
+ }
+ err = symlink(filepath.Join("Versions/Current/Modules"), filepath.Join(frameworkDir, "Modules"))
if err != nil {
return err
}
}
- err := copyFile(
- headers+"/ref.h",
- srcDir+"/ref.h")
- if err != nil {
- return err
- }
- headerFiles = append(headerFiles, title+".h")
- err = writeFile(headers+"/"+title+".h", func(w io.Writer) error {
- return iosBindHeaderTmpl.Execute(w, map[string]interface{}{
- "pkgs": pkgs, "title": title, "bases": fileBases,
- })
- })
- if err != nil {
- return err
- }
}
- resources := buildO + "/Versions/A/Resources"
- if err := mkdir(resources); err != nil {
- return err
- }
- if err := symlink("Versions/Current/Resources", buildO+"/Resources"); err != nil {
- return err
- }
- if err := writeFile(buildO+"/Resources/Info.plist", func(w io.Writer) error {
- _, err := w.Write([]byte(iosBindInfoPlist))
- return err
- }); err != nil {
- return err
+ // Finally combine all frameworks to an XCFramework
+ xcframeworkArgs := []string{"-create-xcframework"}
+
+ for _, dir := range frameworkDirs {
+ xcframeworkArgs = append(xcframeworkArgs, "-framework", dir)
}
- var mmVals = struct {
- Module string
- Headers []string
- }{
- Module: title,
- Headers: headerFiles,
- }
- err = writeFile(buildO+"/Versions/A/Modules/module.modulemap", func(w io.Writer) error {
- return iosModuleMapTmpl.Execute(w, mmVals)
- })
- if err != nil {
- return err
- }
- return symlink("Versions/Current/Modules", buildO+"/Modules")
+ xcframeworkArgs = append(xcframeworkArgs, "-output", buildO)
+ cmd = exec.Command("xcodebuild", xcframeworkArgs...)
+ err = runCmd(cmd)
+ return err
}
const iosBindInfoPlist = `<?xml version="1.0" encoding="UTF-8"?>
diff --git a/cmd/gomobile/bind_test.go b/cmd/gomobile/bind_test.go
index 9a5ffa8..fed8142 100644
--- a/cmd/gomobile/bind_test.go
+++ b/cmd/gomobile/bind_test.go
@@ -112,7 +112,7 @@
}()
buildN = true
buildX = true
- buildO = "Asset.framework"
+ buildO = "Asset.xcframework"
buildTarget = "ios/arm64"
tests := []struct {
@@ -126,7 +126,7 @@
prefix: "Foo",
},
{
- out: "Abcde.framework",
+ out: "Abcde.xcframework",
},
}
for _, tc := range tests {
@@ -160,7 +160,7 @@
BitcodeEnabled bool
}{
outputData: output,
- Output: buildO[:len(buildO)-len(".framework")],
+ Output: buildO[:len(buildO)-len(".xcframework")],
Prefix: tc.prefix,
BitcodeEnabled: bitcodeEnabled,
}
@@ -195,26 +195,28 @@
var bindIOSTmpl = template.Must(template.New("output").Parse(`GOMOBILE={{.GOPATH}}/pkg/gomobile
WORK=$WORK
GOOS=darwin CGO_ENABLED=1 gobind -lang=go,objc -outdir=$WORK -tags=ios{{if .Prefix}} -prefix={{.Prefix}}{{end}} golang.org/x/mobile/asset
+rm -r -f "{{.Output}}.xcframework"
mkdir -p $WORK/src
PWD=$WORK/src GOOS=darwin GOARCH=arm64 CC=iphoneos-clang CXX=iphoneos-clang++ CGO_CFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_CXXFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_LDFLAGS=-isysroot=iphoneos -miphoneos-version-min=7.0 {{if .BitcodeEnabled}}-fembed-bitcode {{end}}-arch arm64 CGO_ENABLED=1 GOPATH=$WORK:$GOPATH go build -tags ios -x -buildmode=c-archive -o $WORK/{{.Output}}-arm64.a ./gobind
-rm -r -f "{{.Output}}.framework"
-mkdir -p {{.Output}}.framework/Versions/A/Headers
-ln -s A {{.Output}}.framework/Versions/Current
-ln -s Versions/Current/Headers {{.Output}}.framework/Headers
-ln -s Versions/Current/{{.Output}} {{.Output}}.framework/{{.Output}}
-xcrun lipo -create -arch arm64 $WORK/{{.Output}}-arm64.a -o {{.Output}}.framework/Versions/A/{{.Output}}
-cp $WORK/src/gobind/{{.Prefix}}Asset.objc.h {{.Output}}.framework/Versions/A/Headers/{{.Prefix}}Asset.objc.h
-mkdir -p {{.Output}}.framework/Versions/A/Headers
-cp $WORK/src/gobind/Universe.objc.h {{.Output}}.framework/Versions/A/Headers/Universe.objc.h
-mkdir -p {{.Output}}.framework/Versions/A/Headers
-cp $WORK/src/gobind/ref.h {{.Output}}.framework/Versions/A/Headers/ref.h
-mkdir -p {{.Output}}.framework/Versions/A/Headers
-mkdir -p {{.Output}}.framework/Versions/A/Headers
-mkdir -p {{.Output}}.framework/Versions/A/Resources
-ln -s Versions/Current/Resources {{.Output}}.framework/Resources
-mkdir -p {{.Output}}.framework/Resources
-mkdir -p {{.Output}}.framework/Versions/A/Modules
-ln -s Versions/Current/Modules {{.Output}}.framework/Modules
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Headers
+ln -s A $WORK/arm64/{{.Output}}.framework/Versions/Current
+ln -s Versions/Current/Headers $WORK/arm64/{{.Output}}.framework/Headers
+ln -s Versions/Current/{{.Output}} $WORK/arm64/{{.Output}}.framework/{{.Output}}
+xcrun lipo -create -arch arm64 $WORK/{{.Output}}-arm64.a -o $WORK/arm64/{{.Output}}.framework/Versions/A/{{.Output}}
+cp $WORK/src/gobind/{{.Prefix}}Asset.objc.h $WORK/arm64/{{.Output}}.framework/Versions/A/Headers/{{.Prefix}}Asset.objc.h
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Headers
+cp $WORK/src/gobind/Universe.objc.h $WORK/arm64/{{.Output}}.framework/Versions/A/Headers/Universe.objc.h
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Headers
+cp $WORK/src/gobind/ref.h $WORK/arm64/{{.Output}}.framework/Versions/A/Headers/ref.h
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Headers
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Headers
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Resources
+ln -s Versions/Current/Resources $WORK/arm64/{{.Output}}.framework/Resources
+mkdir -p $WORK/arm64/{{.Output}}.framework/Resources
+mkdir -p $WORK/arm64/{{.Output}}.framework/Versions/A/Modules
+ln -s Versions/Current/Modules $WORK/arm64/{{.Output}}.framework/Modules
+xcrun lipo $WORK/arm64/{{.Output}}.framework/Versions/A/{{.Output}} -thin arm64 -output $WORK/arm64/{{.Output}}.framework/Versions/A/{{.Output}}
+xcodebuild -create-xcframework -framework $WORK/arm64/{{.Output}}.framework -framework $WORK/amd64/{{.Output}}.framework -framework $WORK/catalyst/{{.Output}}.framework -output {{.Output}}.xcframework
`))
func TestBindIOSAll(t *testing.T) {
@@ -231,7 +233,7 @@
}()
buildN = true
buildX = true
- buildO = "Asset.framework"
+ buildO = "Asset.xcframework"
buildTarget = "ios"
buf := new(bytes.Buffer)
@@ -291,7 +293,7 @@
case "android":
out = filepath.Join(dir, "cgopkg.aar")
case "ios":
- out = filepath.Join(dir, "Cgopkg.framework")
+ out = filepath.Join(dir, "Cgopkg.xcframework")
}
tests := []struct {
diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
index 6dacc63..b342f3e 100644
--- a/cmd/gomobile/env.go
+++ b/cmd/gomobile/env.go
@@ -36,6 +36,27 @@
}
}
+// iOSTargets lists Apple platforms as individual sub-targets.
+// The gomobile "ios" target actually builds for multiple Apple platforms:
+// iOS, iPadOS, MacCatalyst (iOS on macOS), and macOS.
+// TODO: support watchOS and tvOS?
+var iOSTargets = []string{"simulator", "ios", "catalyst", "macos"}
+
+func iOSTargetArchs(target string) []string {
+ switch target {
+ case "simulator":
+ return []string{"arm64", "amd64"}
+ case "ios":
+ return []string{"arm64"}
+ case "catalyst":
+ return []string{"arm64", "amd64"}
+ case "macos":
+ return []string{"arm64", "amd64"}
+ default:
+ panic(fmt.Sprintf("unexpected iOS target: %s", target))
+ }
+}
+
func buildEnvInit() (cleanup func(), err error) {
// Find gomobilepath.
gopath := goEnv("GOPATH")
@@ -141,38 +162,52 @@
darwinArmNM = "nm"
darwinEnv = make(map[string][]string)
- for _, arch := range allArchs("ios") {
- var env []string
- var err error
- var clang, cflags string
- switch arch {
- case "arm64":
- clang, cflags, err = envClang("iphoneos")
- cflags += " -miphoneos-version-min=" + buildIOSVersion
- case "amd64":
- clang, cflags, err = envClang("iphonesimulator")
- cflags += " -mios-simulator-version-min=" + buildIOSVersion
- default:
- panic(fmt.Errorf("unknown GOARCH: %q", arch))
- }
- if err != nil {
- return err
- }
+ for _, target := range iOSTargets {
+ for _, arch := range iOSTargetArchs(target) {
+ var env []string
+ var err error
+ var clang, cflags string
+ switch target {
+ case "ios":
+ clang, cflags, err = envClang("iphoneos")
+ cflags += " -miphoneos-version-min=" + buildIOSVersion
+ case "simulator":
+ clang, cflags, err = envClang("iphonesimulator")
+ cflags += " -mios-simulator-version-min=" + buildIOSVersion
+ case "catalyst":
+ clang, cflags, err = envClang("macosx")
+ switch arch {
+ case "amd64":
+ cflags += " -target x86_64-apple-ios13.0-macabi"
+ case "arm64":
+ cflags += " -target arm64-apple-ios13.0-macabi"
+ }
+ case "macos":
+ // Note: the SDK is called "macosx", not "macos"
+ clang, cflags, err = envClang("macosx")
+ default:
+ panic(fmt.Errorf("unknown ios target: %q", arch))
+ }
- if bitcodeEnabled {
- cflags += " -fembed-bitcode"
+ if err != nil {
+ return err
+ }
+
+ if bitcodeEnabled {
+ cflags += " -fembed-bitcode"
+ }
+ env = append(env,
+ "GOOS=darwin",
+ "GOARCH="+arch,
+ "CC="+clang,
+ "CXX="+clang+"++",
+ "CGO_CFLAGS="+cflags+" -arch "+archClang(arch),
+ "CGO_CXXFLAGS="+cflags+" -arch "+archClang(arch),
+ "CGO_LDFLAGS="+cflags+" -arch "+archClang(arch),
+ "CGO_ENABLED=1",
+ )
+ darwinEnv[target+"_"+arch] = env
}
- env = append(env,
- "GOOS=darwin",
- "GOARCH="+arch,
- "CC="+clang,
- "CXX="+clang+"++",
- "CGO_CFLAGS="+cflags+" -arch "+archClang(arch),
- "CGO_CXXFLAGS="+cflags+" -arch "+archClang(arch),
- "CGO_LDFLAGS="+cflags+" -arch "+archClang(arch),
- "CGO_ENABLED=1",
- )
- darwinEnv[arch] = env
}
return nil
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.
Hajime Hoshi has created a revert of this change.
To view, visit change 310949. To unsubscribe, or for help writing mail filters, visit settings.