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: bind framework not found by Xcode #35641

Open
pontusntengnas opened this issue Nov 16, 2019 · 11 comments

Comments

@pontusntengnas
Copy link

@pontusntengnas pontusntengnas commented Nov 16, 2019

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

$ go version
go version go1.13.4 darwin/amd64

Does this issue reproduce with the latest release?

I believe I am on the latest version

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/pontusnt/Library/Caches/go-build"
GOENV="/Users/pontusnt/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="MY_GO_PATH"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
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/68/_7g0dkds1zx17wwpnmh6k4wr0000gn/T/go-build239061966=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

gomobile bind -o frameworks/ios/Shared.framework -target=ios

This completed successfully and I got a folder named Shared.Framework with obj-c files.

I drag and drop this into Xcode 11.2.1 (11B500) to use it in my app.

What did you expect to see?

I expected to be able to compile the app and use the framework in my Swift code.

What did you see instead?

The Xcode project no longer compiles, but fails with:

ld: framework not found Shared clang: error: linker command failed with exit code 1 (use -v to see invocation)

I alos tried adding the absolut path to Xcode build setting Framework search paths without success.

Thankful for your help!

@gopherbot gopherbot added this to the Unreleased milestone Nov 16, 2019
@gopherbot gopherbot added the mobile label Nov 16, 2019
@andybons

This comment has been minimized.

Copy link
Member

@andybons andybons commented Nov 18, 2019

@eliasnaur

This comment has been minimized.

Copy link
Contributor

@eliasnaur eliasnaur commented Nov 18, 2019

I alos tried adding the absolut path to Xcode build setting Framework search paths without success.

FWIW, this works for me in Xcode 11.1. Did you add the path to the framework ("/path/to/Shared.framework") or the path to the containing directory ("/path/to")? Xcode expects the latter.

@pontusntengnas

This comment has been minimized.

Copy link
Author

@pontusntengnas pontusntengnas commented Nov 18, 2019

Thanks for you reply. I tried both of them without success. I really cannot understand why this is happening, there is a framework in that folder. I do not know if it matters but it is just a folder called "Shared.Framework" containing the files and not that "Lego-ish" icon that i have seen some frameworks have.

The app is targeting iOS 13.

I get the exact same issue trying to use the example at
go get -d golang.org/x/mobile/example/bind/...

@pontusntengnas

This comment has been minimized.

Copy link
Author

@pontusntengnas pontusntengnas commented Nov 18, 2019

Am I missing something? I drag n drop the framework into Xcode and it shows up nicely under "Frameworks, Libraries, and embedded content". Then I added the framework search path and tried to build.

@eliasnaur

This comment has been minimized.

Copy link
Contributor

@eliasnaur eliasnaur commented Nov 18, 2019

I installed Xcode 11.2.1 with no change: the bind example builds successfully.

Thanks for you reply. I tried both of them without success. I really cannot understand why this is happening, there is a framework in that folder. I do not know if it matters but it is just a folder called "Shared.Framework" containing the files and not that "Lego-ish" icon that i have seen some frameworks have.

Did you name the framework "Shared.Framework" or "Shared.framework"?

@pontusntengnas

This comment has been minimized.

Copy link
Author

@pontusntengnas pontusntengnas commented Nov 19, 2019

I am using "Shared.framework". Capital F gives me an error when binding.

@pontusntengnas

This comment has been minimized.

Copy link
Author

@pontusntengnas pontusntengnas commented Nov 24, 2019

Okey I got it working now! What was causing the issue was probably my use of the name "Shared" when there where no Go package called "shared" in the files I was binding.

If i omit the naming of the output -o and just bind it, the frameworks gets a different name but this frameworks gets found by Xcode and can be used, awesome!

But then a follow up question, is it not possible to name my framework to something custom?

In my case I am binding 3 different Go packages and want to create a single output framework of that. I do this like this:

gomobile bind -target=ios \ services/departure \ services/search \ presenters

And then the name of the framework becomes Departure, so I guess it just gets the name of the first package argument I give to bind.

So it works but it would be nice to name it something else. And am I doing it right when binding my 3 packages like I do?

Thanks.

@eliasnaur

This comment has been minimized.

Copy link
Contributor

@eliasnaur eliasnaur commented Nov 24, 2019

Can you send a complete example, with you xcode project ready to use and a set of packages for gomobile bind? The easier it is to reproduce, the better.

@hajimehoshi

@pontusntengnas

This comment has been minimized.

Copy link
Author

@pontusntengnas pontusntengnas commented Nov 24, 2019

I do not see it is as necessary as it is working for me now. Now I just wonder if I can have a custom name on the .framework output and if the way I am binding the three packages is the correct way to do it, see my above comment.

@eliasnaur

This comment has been minimized.

Copy link
Contributor

@eliasnaur eliasnaur commented Nov 24, 2019

@pontusntengnas

This comment has been minimized.

Copy link
Author

@pontusntengnas pontusntengnas commented Nov 25, 2019

Ok I see I will try to find time to make an example and attach here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.