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

Comments

Projects
None yet
3 participants
@adam-p
Copy link

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

This comment has been minimized.

Copy link
Member

commented Jan 17, 2017

@rakyll rakyll added this to the Unreleased milestone Jan 17, 2017

@gopherbot

This comment has been minimized.

Copy link

commented Jan 17, 2017

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

@golang golang locked and limited conversation to collaborators Jan 18, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.