-
Notifications
You must be signed in to change notification settings - Fork 18k
x/mobile: bind framework not found by Xcode #35641
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
Comments
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. |
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 |
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. |
I installed Xcode 11.2.1 with no change: the bind example builds successfully.
Did you name the framework "Shared.Framework" or "Shared.framework"? |
I am using "Shared.framework". Capital F gives me an error when binding. |
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 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:
And then the name of the framework becomes 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. |
Can you send a complete example, with you xcode project ready to use and a set of packages for |
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. |
On Sun Nov 24, 2019 at 9:19 AM Pontus Nilsson Tengnäs wrote:
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.
The `-o` option should let you name your framework any way you want,
providing the name ends with `.framework`. That's why I wanted you
to provide us with exact reproduction steps.
|
Ok I see I will try to find time to make an example and attach here. |
We ran into the same issue when upgrading from xcode 10.3 to 11.3.1. Triggered by #35641 (comment) we finally figured out that we had to change the |
I ran into the same issue today, and thanks to @pontusntengnas , I resolve it by omitting I made a simple example and hope it helps @eliasnaur Env
go envGO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/Users/guolin/Library/Caches/go-build" GOENV="/Users/guolin/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/guolin/Work/go" GOPRIVATE="" GOPROXY="https://goproxy.io,direct" GOROOT="/usr/local/Cellar/go/1.14.3/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.14.3/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/guolin/Work/colin/go/issue/gogo/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 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0k/r288ywwx49zcyx8dpgh5tt5r0000gn/T/go-build768315077=/tmp/go-build -gno-record-gcc-switches -fno-common" ReproduceDownload the issue.zip file then extract, will get two projects:
cd gogo
gomobile bind -o gogo.framework -a -ldflags '-s -w' -target=ios gogo.go/fly gogo.go/swim
hope it helps |
It appears that if the framework name is different from the name of the package that was built, this ld not found error will be thrown.
I notice that So it kinda makes sense that when @FallenLord removed -o it worked because gomobile will have used the actual package name which you would use when importing. Could this be a bug in gomobile? If so, I think the framework name from the -o flag should take precedence over the golang package name being bound. |
So, fixing modulemap by using the specified framework name would solve this issue? That makes sense. I'll take a look next week. |
That’s my guess. It may need testing on Android and iOS apps. Happy to spend some time contributing to that @hajimehoshi. |
Change https://golang.org/cl/239237 mentions this issue: |
When the module name in *.modulemap and the framework name don't match, Xcode fails to find the framework. This CL fixes this issue by using the specified .framework name for the module name. Fixes golang/go#35641 Change-Id: I0df5335f2d64f0529e7357c2d04af5eaf760a879 Reviewed-on: https://go-review.googlesource.com/c/mobile/+/239237 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
When the module name in *.modulemap and the framework name don't match, Xcode fails to find the framework. This CL fixes this issue by using the specified .framework name for the module name. Fixes golang/go#35641 Change-Id: I0df5335f2d64f0529e7357c2d04af5eaf760a879 Reviewed-on: https://go-review.googlesource.com/c/mobile/+/239237 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
When the module name in *.modulemap and the framework name don't match, Xcode fails to find the framework. This CL fixes this issue by using the specified .framework name for the module name. Fixes golang/go#35641 Change-Id: I0df5335f2d64f0529e7357c2d04af5eaf760a879 Reviewed-on: https://go-review.googlesource.com/c/mobile/+/239237 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
What version of Go are you using (
go version
)?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
OutputWhat 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!
The text was updated successfully, but these errors were encountered: