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/cmd/gomobile: issues linking frameworks in Xcode #28517

Closed
taybart opened this issue Oct 31, 2018 · 5 comments
Closed

x/mobile/cmd/gomobile: issues linking frameworks in Xcode #28517

taybart opened this issue Oct 31, 2018 · 5 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Milestone

Comments

@taybart
Copy link

taybart commented Oct 31, 2018

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

go: 1.11.1 (also 1.11 and 1.10.3 were tested)
gomobile: master (a27dd33d354d004b2de14a791df5af8a00f68b8e)
Xcode: 10.1 (10B61)

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/taybartski/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/taybarski/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.1/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/vw/bxwt77n10r90nc1dbrjgt31m0000gn/T/go-build422606684=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

[This was after gomobile/golang/xcode update]

I was successfully using gomobile bind, it seems that something with the build process has changed. I have a .framework that I generated last week that still works, however, the new ones that I create are failing to link in the newest Xcode.

The output below was generated with the example from the wiki. This may be an Xcode issue, but the fact that the old .framework is still compiling makes be think it may be in gomobile.

Looking at the lastest change that happened in gomobile, it seems unlikely that it is that. I am at a loss though. Xcode was updated along with the command line tools. Any insight would be very helpful.

What did you expect to see?

Successful linking of .framework

What did you see instead?

Xcode error:

ld: warning: ignoring file /Users/taybartski/go/src/golang.org/x/mobile/example/bind/ios/Hello.framework/Hello, file is universal (4 slices) but does not contain the x86_64 architecture: /Users/taybartski/go/src/golang.org/x/mobile/example/bind/ios/Hello.framework/Hello
Undefined symbols for architecture x86_64:
  "_HelloGreetings", referenced from:
      -[ViewController loadView] in ViewController.o
ld: symbol(s) not found for architecture x86_64
$ file Hello.framework/Hello
Hello.framework/Hello: Mach-O universal binary with 4 architectures: [arm_v7:current ar archive] [arm64]
Hello.framework/Hello (for architecture armv7): current ar archive
Hello.framework/Hello (for architecture i386):  current ar archive
Hello.framework/Hello (for architecture x86_64):        current ar archive
Hello.framework/Hello (for architecture arm64): current ar archive
@gopherbot gopherbot added this to the Unreleased milestone Oct 31, 2018
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Oct 31, 2018
@taybart
Copy link
Author

taybart commented Oct 31, 2018

ld command:

Ld /Users/taybartski/Library/Developer/Xcode/DerivedData/Hello-czuinjavcxpbnxgmovcdbcxuijgw/Build/Products/Debug-iphonesimulator/Hello.app/Hello normal x86_64 (in target: Hello)
    cd /Users/taybartski/dev/projects/Hello
    export IPHONEOS_DEPLOYMENT_TARGET=12.0
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -L/Users/taybartski/Library/Developer/Xcode/DerivedData/Hello-czuinjavcxpbnxgmovcdbcxuijgw/Build/Products/Debug-iphonesimulator -F/Users/taybartski/Library/Developer/Xcode/DerivedData/Hello-czuinjavcxpbnxgmovcdbcxuijgw/Build/Products/Debug-iphonesimulator -F/Users/taybartski/dev/projects/Hello -F/Users/taybartski/dev/projects/Hello/Hello -filelist /Users/taybartski/Library/Developer/Xcode/DerivedData/Hello-czuinjavcxpbnxgmovcdbcxuijgw/Build/Intermediates.noindex/Hello.build/Debug-iphonesimulator/Hello.build/Objects-normal/x86_64/Hello.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=12.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/taybartski/Library/Developer/Xcode/DerivedData/Hello-czuinjavcxpbnxgmovcdbcxuijgw/Build/Intermediates.noindex/Hello.build/Debug-iphonesimulator/Hello.build/Objects-normal/x86_64/Hello_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/taybartski/Library/Developer/Xcode/DerivedData/Hello-czuinjavcxpbnxgmovcdbcxuijgw/Build/Intermediates.noindex/Hello.build/Debug-iphonesimulator/Hello.build/Objects-normal/x86_64/Hello.swiftmodule -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/taybartski/Library/Developer/Xcode/DerivedData/Hello-czuinjavcxpbnxgmovcdbcxuijgw/Build/Intermediates.noindex/Hello.build/Debug-iphonesimulator/Hello.build/Hello.app-Simulated.xcent -framework Libjourney -Xlinker -dependency_info -Xlinker /Users/taybartski/Library/Developer/Xcode/DerivedData/Hello-czuinjavcxpbnxgmovcdbcxuijgw/Build/Intermediates.noindex/Hello.build/Debug-iphonesimulator/Hello.build/Objects-normal/x86_64/Hello_dependency_info.dat -o /Users/taybartski/Library/Developer/Xcode/DerivedData/Hello-czuinjavcxpbnxgmovcdbcxuijgw/Build/Products/Debug-iphonesimulator/Hello.app/Hello
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@taybart
Copy link
Author

taybart commented Jan 24, 2019

Reinstalling macOS fixed the issue for me. I don't like that as a fix though...

@taybart taybart closed this as completed Jan 24, 2019
@zhj4478
Copy link

zhj4478 commented Mar 6, 2019

@taybart @gopherbot @sashabaranov
I have the same issue previously.
I found I have binutils(v2.3.2) installed through the homebrew that overrides the same libs from the macOS. After I unlink the binutils the issue is solved. I also tried to downgrade it to (v2.3.1) and it works as well.

I hope this could help who has a similar issue like this.

@karvar
Copy link

karvar commented Mar 20, 2019

I am running into the same issue with adding my framework to Xcode. I think that reinstalling macOS is not a fix I would think is feasible. binutils did not work for me either. I am adding the .framework to a cocoapod and the podspecs are as follows:

  s.source_files = [
    'SDK/Classes/*.swift',
    'SDK/Classes/SHTTP.framework/**/*',
  ]
  s.exclude_files = 'SDK/Classes/SHTTP.framework/Versions/**/*'
  s.pod_target_xcconfig = {
    'OTHER_LDFLAGS' => '$(inherited) -ObjC'
  }

My binary file is as follows:

$ file HTTP.framework/HTTP 
HTTP.framework/HTTP: Mach-O universal binary with 4 architectures: [arm_v7:current ar archive random library] [arm64]
HTTP.framework/Pokemon (for architecture armv7): current ar archive random library
HTTP.framework/Pokemon (for architecture i386):  current ar archive random library
HTTP.framework/Pokemon (for architecture x86_64):        current ar archive random library
HTTP.framework/Pokemon (for architecture arm64): current ar archive random library

@karvar
Copy link

karvar commented Apr 1, 2019

I added it as a vendored framework and still having the same issue:
s.ios.vendored_frameworks = ['Sdk.framework', 'HTTP.framework']

@golang golang locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

4 participants