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/bind: Avoid using objective-c reserved keywords as ids. (e.g. id) #12958

Closed
endeveit opened this issue Oct 16, 2015 · 2 comments
Closed
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Milestone

Comments

@endeveit
Copy link

With gomobile version golang/mobile@82d11f2, go1.5.1 darwin/amd64, gomobile bind fails for -target ios with the following test package:

package BindTest

type Client struct {
}

type Files struct {
    files [][]byte
}

func (c *Client) AddPhotosToId(id int, f *Files) (result string, err error) {
    return
}

Android target builds successfully.
iOS target build fails:

gomobile: darwin-armv7: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -I . -g -O2 -o gobind-BindTest-arm.o -fobjc-arc -c GoBindTest.m -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk -arch armv7 failed: exit status 1
GoBindTest.m:36:11: error: unexpected interface name 'NSObject': expected expression
        if ([(id<NSObject>)(f) isKindOfClass:[GoBindTestFiles class]]) {
                 ^
GoBindTest.m:36:20: error: expected expression
        if ([(id<NSObject>)(f) isKindOfClass:[GoBindTestFiles class]]) {
                          ^
GoBindTest.m:37:6: error: use of undeclared identifier 'goSeqRefInterface'
                id<goSeqRefInterface> f_proxy = (id<goSeqRefInterface>)(f);
                   ^
GoBindTest.m:37:25: error: use of undeclared identifier 'f_proxy'
                id<goSeqRefInterface> f_proxy = (id<goSeqRefInterface>)(f);
                                      ^
GoBindTest.m:37:39: error: use of undeclared identifier 'goSeqRefInterface'
                id<goSeqRefInterface> f_proxy = (id<goSeqRefInterface>)(f);
                                                    ^
GoBindTest.m:37:57: error: expected expression
                id<goSeqRefInterface> f_proxy = (id<goSeqRefInterface>)(f);
                                                                      ^
GoBindTest.m:38:25: error: use of undeclared identifier 'f_proxy'
                go_seq_writeRef(&in_, f_proxy._ref);
                                      ^
7 errors generated.

If you change method signature to this one, target builds successfully:

func (c *Client) AddPhotosToId(identifier int, f *Files) (result string, err error) {
    return
}

Maybe it's because of "id" is reserved word in ObjC.

@hyangah hyangah self-assigned this Oct 16, 2015
@hyangah hyangah changed the title x/mobile/bind: syntax error in generated ObjC code when using "id" as variable name in method arguments x/mobile/bind: Avoid using objective-c reserved keywords as ids. (e.g. id) Oct 16, 2015
@rsc rsc added this to the Unreleased milestone Oct 23, 2015
@cvermilion
Copy link

Just hit this -- definitely non-trivial to figure out what the actual issue is. It'd be very helpful for gomobile to give you a warning if you use reserved words as parameter names.

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

Fixed in https://golang.org/cl/28592.

@golang golang locked and limited conversation to collaborators Mar 16, 2019
@rsc rsc unassigned hyangah Jun 23, 2022
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

6 participants