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: go_seq_go_to_refnum on objective-c objects is not permitted #20254

Closed
karalabe opened this issue May 5, 2017 · 6 comments
Closed
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Milestone

Comments

@karalabe
Copy link
Contributor

karalabe commented May 5, 2017

We've received a bug report that recently (2+ weeks at least) iOS builds have been erroring out with a strange error. Any ideas about it?

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'go_seq_go_to_refnum on objective-c objects is not permitted'
@gopherbot gopherbot added this to the Unreleased milestone May 5, 2017
@sashabaranov
Copy link

sashabaranov commented May 11, 2017

Also experiencing this.

Happens to me when I manually instantiate golang's struct and then perform some actions with its internals.

MygolangObject* obj = [[MygolangObject alloc] init];
[obj setProperty:value]; // fails here

However it works if I introduce procedure to create objects in golang:

MygolangObject* obj = MygolangFunctionToCreateObject(property_value);
[obj setProperty:value]; // works!

@ArEnSc
Copy link

ArEnSc commented Jun 30, 2017

I don’t understand how this works can you clearify ? With a full example ?

@zgramana
Copy link

I noticed the error when I implemented the generated class declared by gomobile from my Go interface which included the _ref property. When I declared my own class and implemented the protocol which mapped directly to my Go interface (without _ref) it worked as expected.

@gabriel
Copy link

gabriel commented Jul 11, 2017

You can't use alloc/init to make a go struct.. You have to create a constructor in go code and call that.

No:

MyObject* obj = [[MyObject alloc] init];

Yes:

func NewMyObject() *MyObject {
  return &MyObject{...}
}
MyObject* obj = TheFrameworkNewMyObject();

@bradfitz bradfitz added the mobile Android, iOS, and x/mobile label Jul 20, 2017
@gopherbot
Copy link

Change https://golang.org/cl/51870 mentions this issue: bind: mark default ObjC initializer unavailable

@gopherbot
Copy link

Change https://golang.org/cl/52012 mentions this issue: bind: generate ObjC initializers

@golang golang locked and limited conversation to collaborators Aug 11, 2018
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
For functions on the form

New<T>... (...) *T

or

New<T>... (...) (*T, error)

generate corresponding initializers. The name of an initializer is
the function name where "New<T>" is replaced by "init".

If no functions match for a type *T, generate a default (empty)
initializer that returns new(T). The default initializer mirrors
the default constructor in Java.

Fixes golang/go#20254.

Change-Id: I3c317418fa517d3f2de3f67f400867285b11ea4f
Reviewed-on: https://go-review.googlesource.com/52012
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
For functions on the form

New<T>... (...) *T

or

New<T>... (...) (*T, error)

generate corresponding initializers. The name of an initializer is
the function name where "New<T>" is replaced by "init".

If no functions match for a type *T, generate a default (empty)
initializer that returns new(T). The default initializer mirrors
the default constructor in Java.

Fixes golang/go#20254.

Change-Id: I3c317418fa517d3f2de3f67f400867285b11ea4f
Reviewed-on: https://go-review.googlesource.com/52012
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

7 participants