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: No type or protocol named 'goSeqRefInterface' #17482

Closed
aylesm opened this issue Oct 17, 2016 · 5 comments
Closed

x/mobile: No type or protocol named 'goSeqRefInterface' #17482

aylesm opened this issue Oct 17, 2016 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@aylesm
Copy link

aylesm commented Oct 17, 2016

Please answer these questions before submitting your issue. Thanks!

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

go version go1.7.1 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/michaelayles/Documents/Melrose/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/d2/vr1s6x2j30d52plx6fgy0h480000gn/T/go-build939087427=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

If possible, provide a recipe for reproducing the error.
I've downloaded the latest gomobile version following the instructions online. The version I have now is "gomobile version +2ea7e2c Mon Oct 17 14:21:52 2016 +0000 (android,ios); androidSDK="

I'm trying to build a framework for iOS, which succeeds. But compiling and running against an iOS app fails.

The generated interface contains references that are not defined anywhere.

Error 1: Use of '@import' when modules are disabled

Multiple Errors for every: GoUniverse.h:22:39: No type or protocol named 'goSeqRefInterface'

Example. I've defined a struct in Go:

type Location struct {
    Timestamp int64
    Latitude  float64
    Longitude float64
    Speed     float64
    Course    float64
    Altitude  float64
    Accuracy  float64
}

This generates an interface as this...

@interface GoReachSDKLocation : NSObject <goSeqRefInterface> {
}
@property(strong, readonly) id _ref;

- (id)initWithRef:(id)ref;
- (int64_t)timestamp;
- (void)setTimestamp:(int64_t)v;
- (double)latitude;
- (void)setLatitude:(double)v;
- (double)longitude;
- (void)setLongitude:(double)v;
- (double)speed;
- (void)setSpeed:(double)v;
- (double)course;
- (void)setCourse:(double)v;
- (double)altitude;
- (void)setAltitude:(double)v;
- (double)accuracy;
- (void)setAccuracy:(double)v;
@end

This doesn't compile.

A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

Should compile. Previous version of goMobile didn't use goSeqRefInterface. Output was:

@interface GoReachSDKLocation : NSObject  {
}
@property(strong, readonly) id _ref;

- (id)initWithRef:(id)ref;
- (int64_t)timestamp;
- (void)setTimestamp:(int64_t)v;
- (double)latitude;
- (void)setLatitude:(double)v;
- (double)longitude;
- (void)setLongitude:(double)v;
- (double)speed;
- (void)setSpeed:(double)v;
- (double)course;
- (void)setCourse:(double)v;
- (double)altitude;
- (void)setAltitude:(double)v;
- (double)accuracy;
- (void)setAccuracy:(double)v;
@end

What did you see instead?

Doesn't compile.

@quentinmit quentinmit changed the title x/mobile: x/mobile: No type or protocol named 'goSeqRefInterface' Oct 17, 2016
@quentinmit quentinmit added this to the Unreleased milestone Oct 17, 2016
@quentinmit quentinmit added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 17, 2016
@crawshaw
Copy link
Member

cc @eliasnaur

@eliasnaur
Copy link
Contributor

eliasnaur commented Oct 18, 2016

The Error 1: Use of '@import' when modules are disabled is probably the culprit. Are modules disabled in your project?

@aylesm
Copy link
Author

aylesm commented Oct 18, 2016

Modules appear to be enabled. Certainly nothing has changed apart an update to gomobile.

@eliasnaur
Copy link
Contributor

The bind generators have started to use the @import module import syntax, which explains why it fails for you by just upgrading gomobile. However, it should work as long as modules are enabled in your project.

Do the golang.org/x/mobile/example/bind/ios example work for you? I ran

$ gomobile bind -target=ios golang.org/x/mobile/example/bind/hello

in that directory and dragged the resulting Hello.framework into the example project. The example then ran fine in the emulator.

@aylesm
Copy link
Author

aylesm commented Oct 19, 2016

OK I've found the issue. I was calling my go code from *.mm file. Which despite project settings disables modules. I moved to using a *.m file and my project compiles. Probably worth calling that out in the docs.

@aylesm aylesm closed this as completed Oct 19, 2016
@golang golang locked and limited conversation to collaborators Oct 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants