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: gobind fails on relatively simple example for iOS only #21523

Closed
steeve opened this issue Aug 18, 2017 · 2 comments
Closed

x/mobile: gobind fails on relatively simple example for iOS only #21523

steeve opened this issue Aug 18, 2017 · 2 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Milestone

Comments

@steeve
Copy link
Contributor

steeve commented Aug 18, 2017

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

go version go1.8.3 darwin/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/steeve/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.8.3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.8.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/go-build194780881=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

gomobile bind fails with the following code:

package mypkg

import "context"

type MyStruct struct {
}

func NewMyStruct(ctx context.Context) *MyStruct {
	return nil
}

What did you expect to see?

A successful bind.

What did you see instead?

When trying to build for iOS, this happens:

$ gomobile bind -v -target=ios github.com/steeve/mypkg
write /var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/gomobile-work-008978683/src/gomobile_bind/interfaces.go
write /var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/gomobile-work-008978683/gen/src/ObjC/interfaces.go
write /var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/gomobile-work-008978683/src/gomobile_bind/interfaces.h
write /var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/gomobile-work-008978683/src/gomobile_bind/interfaces.m
write /var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/gomobile-work-008978683/fakegopath/pkg/darwin_arm/github.com/steeve/mypkg.a
write /var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/gomobile-work-008978683/src/gomobile_bind/go_pouetmain.go
write /var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/gomobile-work-008978683/src/gomobile_bind/go_main.go
write /var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/gomobile-work-008978683/src/iosbin/main.go
write /var/folders/bs/51dlb_nn5k35xq9qfsxv9wc00000gn/T/gomobile-work-008978683/src/gomobile_bind/Mypkg.m
gomobile: type Context is in package context, which is not bound

This is due to the ctx parameter for the function.
It does build for Android, however.

@gopherbot gopherbot added this to the Unreleased milestone Aug 18, 2017
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Aug 18, 2017
@steeve
Copy link
Contributor Author

steeve commented Aug 18, 2017

So this is because of golang/mobile@e665403 and the fact that the method is named New*.
Renaming the method fixes the issue.

However, perhaps it should not fail and rather warn? Not sure about the behaviour.

@gopherbot
Copy link

Change https://golang.org/cl/101115 mentions this issue: bind: skip incompatible constructors in ObjC bindings

@golang golang locked and limited conversation to collaborators Mar 21, 2019
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Fixes golang/go#21523

Change-Id: I1244e296ac4eeb0d10847e73216e4a25a3533292
Reviewed-on: https://go-review.googlesource.com/101115
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Fixes golang/go#21523

Change-Id: I1244e296ac4eeb0d10847e73216e4a25a3533292
Reviewed-on: https://go-review.googlesource.com/101115
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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

2 participants