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 · 5 comments
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mycroftcanner
Copy link

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 the mobile Android, iOS, and x/mobile label Apr 27, 2021
@gopherbot gopherbot added this to the Unreleased milestone Apr 27, 2021
@mycroftcanner
Copy link
Author

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 commented Apr 27, 2021

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

@cherrymui
Copy link
Member

cc @hyangah @eliasnaur

@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 27, 2021
@ibigbug
Copy link

ibigbug commented Jun 9, 2021

Having same issue.

@gadireddi226
Copy link

Having same issue too. This will be relevant for all projects that want to be on xcode 12+. There is neccessary to have xcframeworks with iOS and iOS simulator architecture or it will be very problematic for unit tests, building project etc..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants