This fixes the 'unable to import bind' error when
gomobile-tvos-fork is installed via 'go install' and
used to build packages outside the fork's module context.
The fix uses debug.ReadBuildInfo() to determine where the fork is
installed (either in GOPATH/src or module cache) and constructs
paths to bind packages directly, avoiding the dependency on
packages.Load which requires packages to be in the current
module's dependency graph.
The gomobile build command wraps "go build" and parses many build
flags including "-a", but it was not actually passing the "-a" flag
through to the underlying go build command.
The "-a" flag forces a rebuild of packages and dependencies, which
is useful for ensuring clean builds when needed.
Add the missing code to pass the "-a" flag through to the go build
command when buildA is true, matching the pattern used for other
build flags like "-x" and "-gcflags".
Fixesgolang/go#76466.
Change-Id: Icf4b8520611a22b1106d6bbd48e75072697b94a6
GitHub-Last-Rev: 92bbebf3e658de5b87675c10a0ca960ba18da7c5
GitHub-Pull-Request: golang/mobile#114
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/724360
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
This patch updates the framework generation code to follow the Apple spec for placing content:
https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle
Previously, we setup the framework in MacOS format, and used symlinks to make it compatible with iOS format. This approach no longer works (it works locally in simulator, but causes signing issues when attempting to upload apps for distribution, or running on real hardware). We now setup the expected bundle format for each platform.
Other benefits:
- Thirds the size of the xcframework and resulting app binary when distributing the xcframework by zip (common for SPM and other formats). The symlinks resulted in duplicate files after zipping, which made it into the final app.
- Set MinimumOSVersion, fixing SPM compatibility issue
- Eliminates the blank Info.plist
- Initial testing shows this also fixesgolang/go#66406 (code signing issues) as a side effect of using the proper format
Testing:
- Tested all 4 platforms (iOS, simulator, macOS, Catalyst) on Xcode 15.3
Fixesgolang/go#66406Fixesgolang/go#66500
Change-Id: I8538989efe67cb0d2d0496087dcbeca923c3dffe
GitHub-Last-Rev: 28dca85888bedcc5eb44d3c74af6b88cf5121914
GitHub-Pull-Request: golang/mobile#98
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/574055
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This change adds compatibility for Xcode 15.3 to "gomobile bind" for building xcframeworks.
- New blank Info.plist in the *.framework target root
- Add CFBundleExecutable and CFBundleIdentifier to the resource level Info.plist
Tested locally on my framework on Xcode 15.3 (fixes issue) and 15.2 (doesn't create new issues).
Would love to get some more folks to try this fix, to make sure it works broadly.
Note: I'm using the framework name as the bundleID. Some chance of collision here, but didn't want to add a required top level cmd parameter. I don't *think* a collision is a serious concern, but I'm not an apple build system expert.
To test:
- sync my branch
- build go mobile: `go build` in the `cmd/gomobile` dir
- Build your xcframework with this version of go mobile: `gomobile bind ... `
- Launch a project using the xcframework in Xcode 15.3, and run in simulator
Fixesgolang/go#66018
Change-Id: I3e8ee99adb09071aa89a541dc97271a44b552ea3
GitHub-Last-Rev: 6277c7d66a26efa8b9ff99dea191eeb7bef136a6
GitHub-Pull-Request: golang/mobile#96
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/572175
TryBot-Result: Gopher Robot <gobot@golang.org>
TryBot-Bypass: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
On macOS, a temporary directory starts with /var, which is a symbolic
link to /private/var. And in gomobile, a temporary directory is usually
used as a working directly. Unfortunately, xcodebuild in Xcode 15 seems
to have a bug and might not be able to understand fullpaths with
symbolic links. As a workaround, resolve the path with symbolic links by
filepath.EvalSymlinks.
Fixesgolang/go#63141
Change-Id: Ieb684223192fc3e354b79dededaecdb0b25937e6
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/530135
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Hajime Hoshi <hajimehoshi@gmail.com>
go.mod files are automatically generated in a temporary working
directory in order to resolve dependencies. The go.mod files didn't
include go statements, which means a Go compiler tried to resolve
dependencies in the most conservative way. In this way, some paths could
not be resolved as ambiguous paths (e.g. golang.org/x/exp vs
golang.org/x/exp/shiny).
This CL fixes this issue by giving a go statement to the go.mod files.
Fixesgolang/go#62458
Change-Id: Ibabd1974f8cd7a3e01eb89994080e32a7115693a
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/525695
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This change makes building archive files for iOS concurrent for each
architecture and each platform. The strategy is basically the same as
my previous CL for Android: https://go.dev/cl/426274.
This change also specifies GOMODCACHE explicitly when executing Go
commands so that the existing cache is always used. The default
GOMODCACHE is $GOPATH/pkg/mod, and this path varies when a temporary
GOPATH is specified, which results in cold cache.
Before this change (on my MacBook Pro 2020):
$ time go run ./cmd/gomobile/ bind -target ios ./example/bind/hello/
real 0m23.274s
user 0m15.751s
sys 0m10.469s
After this change:
$ time go run ./cmd/gomobile/ bind -target ios ./example/bind/hello/
real 0m8.059s
user 0m13.763s
sys 0m9.004s
Updates golang/go#37902
Updates golang/go#54770
Change-Id: Iaeb077b58c22ab63d28f78972a0af76660883a05
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/442195
Reviewed-by: Changkun Ou <mail@changkun.de>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Gobind utilizes golang.org/x/tools/go/packages.Load to find
the directory of a package. Configure the load configuration
to just find the list of files. Zero load mode is equivalent
to combining NeedName+NeedFiles+NeedCompiledGoFiles bits.
That is unnecessary, and can increase the chance of load
failures. For example, load with the zero load mode may fail
if all the necessary cgo dependencies aren't available in the
system, but that shouldn't be critical for gobind's use case.
Updates golang/go#56292
Change-Id: Ifaf4f43e9053cf4a43fd657a9a394fc13f611576
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/443935
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Using the test binary as the "gobind" command not only avoids the
overhead of recompiling the command, but also allows commands like "go
test -race" to actually test the requested configuration of the
command.
Logging stderr and stdout separately — and logging only stderr by
default — makes the failure messages much easier to spot. (Logging the
combined output as before produced a massive wall of text that tends
to bury the actual errors.)
For golang/go#56292.
Change-Id: Ia11fad19418d9b9004608c76fe512ceab4f247bc
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/443655
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>