Skip to content

x/mobile: iOS project won't compile with framework built by gomobile #32918

Open
@ibigbug

Description

@ibigbug

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

$ go version
go version go1.12.6 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
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/myname/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/myname/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cy/b0lrq2m55js29jlf_hhm4xtc0000gn/T/go-build880588199=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I created a go package and used gomobile to bind it for iOS:

gomobile bind -v  -target=ios mypackage

And then referenced the framework in my iOS project

Then complied the iOS project

What did you expect to see?

The project should compile

What did you see instead?

error messge

ld: in /PATH_TO_THE_FRAMEWORK(go.o), building for iOS, but linking in object file (/PATH_TO_THE_FRAMEWORK(go.o)) built for , for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Activity

added this to the Unreleased milestone on Jul 3, 2019
changed the title [-]x/mobile: [/-] [+]x/mobile: iOS project won't compile with framework built by gomobile[/+] on Jul 3, 2019
bcmills

bcmills commented on Jul 3, 2019

@bcmills
Contributor
bcmills

bcmills commented on Jul 3, 2019

@bcmills
Contributor

Then complied the iOS project

Please provide more concrete steps to reproduce the failure. What commands did you run to compile the project? Which command specifically produced the observed error message?

added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
on Jul 3, 2019
steeve

steeve commented on Jul 3, 2019

@steeve
Contributor

Is the problem in Xcode or gomobile build?
@ibigbug, can you please provide a sample project ?

cc @eliasnaur

ibigbug

ibigbug commented on Jul 3, 2019

@ibigbug
Author

Thanks guys for prompt reply.

I created a sample reproduce here https://github.com/ibigbug/SampleGomobile and put the steps in the README file.

A bit more information might be helpful, I'm using the latest Xcode beta. and it worked with an older version of gomobile, it compiles, but output of that version of gomobile doesn't have bitcode, so I upgraded to the latest gomobile and see this issue.

ibigbug

ibigbug commented on Jul 5, 2019

@ibigbug
Author

ping @steeve @bcmills

I'm using buildmode with c-archive to workaround this, but would be great to know how to fix this

removed
WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
on Jul 8, 2019
bcmills

bcmills commented on Jul 8, 2019

@bcmills
Contributor

@ibigbug, this issue has the help wanted label because the solution is not obvious to me, and I don't know of anyone on the Go project who has the available bandwidth to look into it.

steeve

steeve commented on Jul 9, 2019

@steeve
Contributor

I believe this is linked to golang/mobile@9487ef5

You can either:

  • revert that commit (or jump before it)
  • try go 1.13, which this commit requires (because it has the bitcode commits)
ibigbug

ibigbug commented on Jul 20, 2019

@ibigbug
Author

thanks @steeve

Using go1.13beta is and manually passing CGO_FLAGS with -fembed-bitcode worked for me.

Though I'm building c-archive directly via go build, I haven't tried gomobile again, but I assume it would also work.

ibigbug

ibigbug commented on Jul 21, 2019

@ibigbug
Author

I'm trying to switch back to standard gomobile, however I don't seem to find doc saying how use a particular go version for gomobile.

I tried:

$ gomobile version
gomobile version unknown: binary is out of date, re-install it

$ go1.13beta1 get golang.org/x/mobile/cmd/gomobile

$ gomobile init

$ gomobile version
gomobile version unknown: binary is out of date, re-install it

Can someone point me to a way to upgrade go version for gomoible?

Found similar one #24389

ibigbug

ibigbug commented on Jul 21, 2019

@ibigbug
Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.help wantedmobileAndroid, iOS, and x/mobile

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steeve@ibigbug@bcmills@gopherbot

        Issue actions

          x/mobile: iOS project won't compile with framework built by gomobile · Issue #32918 · golang/go