Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile: building for iOS Simulator, but linking in object file built for iOS, for architecture arm64. #45805

Open
mycroftcanner opened this issue Apr 27, 2021 · 3 comments

Comments

@mycroftcanner
Copy link

@mycroftcanner mycroftcanner commented Apr 27, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16.2 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/Users/x/go/bin"
GOCACHE="/Users/x/Library/Caches/go-build"
GOENV="/Users/x/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/x/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/x/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/x/gcloud/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/z7/33jzmkp96sqdpll82cb2ddph0000gn/T/go-build452940234=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

gomobile bind -target=ios golang.org/x/mobile/example/bind/hello

What did you expect to see?

Framework binaries with multiple platforms are not supported anymore.

gomobile bind should generate a universal xcframework

What did you see instead?

In /Users/x/gcloud/src/example/bind/ios/Hello.framework/Hello(000005.o), building for iOS Simulator, but linking in object file (/Users/x/gcloud/src/example/bind/ios/Hello.framework/Hello(000005.o)) built for iOS, for architecture arm64.

We are supposed to use an xcframework instead

file Hello.framework/Versions/A/Hello
Hello.framework/Versions/A/Hello: Mach-O universal binary with 2 architectures: [x86_64:current ar archive random library] [arm64]
Hello.framework/Versions/A/Hello (for architecture x86_64):	current ar archive random library
Hello.framework/Versions/A/Hello (for architecture arm64):	current ar archive random library
@gopherbot gopherbot added this to the Unreleased milestone Apr 27, 2021
@mycroftcanner
Copy link
Author

@mycroftcanner mycroftcanner commented Apr 27, 2021

Here is a workaround:

mkdir -p iphoneos iphonesimulator
cp -rp Hello.framework iphoneos
mv Hello.framework iphonesimulator

lipo -remove x86_64 ./iphoneos/Hello.framework/Hello -o ./iphoneos/Hello.framework/Hello
lipo -remove arm64 ./iphonesimulator/Hello.framework/Hello -o ./iphonesimulator/Hello.framework/Hello

xcodebuild -create-xcframework -framework iphoneos/Hello.framework -framework iphonesimulator/Hello.framework -output Hello.xcframework
@mycroftcanner
Copy link
Author

@mycroftcanner mycroftcanner commented Apr 27, 2021

It seems Xcode 12.5 requires both x86_64-apple-ios-simulator and arm64-apple-ios-simulator

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Apr 27, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants