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: iOS bind generates bad headers #18693

Closed
adam-p opened this issue Jan 17, 2017 · 2 comments
Closed

x/mobile: iOS bind generates bad headers #18693

adam-p opened this issue Jan 17, 2017 · 2 comments

Comments

@adam-p
Copy link
Contributor

adam-p commented Jan 17, 2017

The short version: The #ifndef lines in the generated headers are preventing the inclusion of the Hello.objc.h content. (Which causes compile errors in a project that tries to use the framework.)

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

go version go1.7.4 darwin/amd64

What did you do?

  1. Get and install current gomobile master (currently golang/mobile@c4d780f).

  2. Compile the iOS bind example (golang/mobile/example/bind/ios).

Now look at the generated headers inside the Hello.framework directory.

Hello.h:

// Objective-C API for talking to the following Go packages
//
//      golang.org/x/mobile/example/bind/hello
//
// File is generated by gomobile bind. Do not edit.
#ifndef __Hello_H__
#define __Hello_H__

#include "Hello.objc.h"
#include "Universe.objc.h"

#endif

Hello.objc.h:

// Objective-C API for talking to golang.org/x/mobile/example/bind/hello Go package.
//   gobind -lang=objc golang.org/x/mobile/example/bind/hello
//
// File is generated by gobind. Do not edit.

#ifndef __Hello_H__
#define __Hello_H__

@import Foundation;
#include "Universe.objc.h"


FOUNDATION_EXPORT NSString* HelloGreetings(NSString* name);

#endif

Note that the two files have the same #ifndef/#define lines. This effectively removes the content of the Hello.objc.h file, causing errors when trying to use the framework.

I don't have a fix for this, but I believe the bug was introduced in golang/mobile@6a96d4c. (Perhaps it was always present with a default prefix.)

Workaround: Use the -prefix flag. The prefix will end up in the #ifndef symbol.

@rakyll
Copy link
Contributor

rakyll commented Jan 17, 2017

/cc @eliasnaur

@gopherbot
Copy link

CL https://golang.org/cl/35330 mentions this issue.

@golang golang locked and limited conversation to collaborators Jan 18, 2018
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Fix manually verified; none of our tests or the hello example fails
without this fix.

While we're here, update the hello iOS example to actually include the
Hello.framework and to use module @import syntax.

Fixes golang/go#18693

Change-Id: Id2edf80e2ed9ed8060ec825369a64f276a3b3c1d
Reviewed-on: https://go-review.googlesource.com/35330
Reviewed-by: David Crawshaw <crawshaw@golang.org>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Fix manually verified; none of our tests or the hello example fails
without this fix.

While we're here, update the hello iOS example to actually include the
Hello.framework and to use module @import syntax.

Fixes golang/go#18693

Change-Id: Id2edf80e2ed9ed8060ec825369a64f276a3b3c1d
Reviewed-on: https://go-review.googlesource.com/35330
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants