bind,cmd: support the empty ObjC prefix

Since the Go package name is already prefixed to generated ObjC
names, the empty extra prefix is useful. Support that by not reverting
to the default extra prefix, "Go", if -prefix "" is specified.

To avoid file name clashes with the Go header files, add ".objc" to
the ObjC-facing header names.

Change-Id: I559fe60d7474521617f23894af247c6019ff2a21
Reviewed-on: https://go-review.googlesource.com/33954
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/bind/bind_test.go b/bind/bind_test.go
index ad9f4d3..c9b8522 100644
--- a/bind/bind_test.go
+++ b/bind/bind_test.go
@@ -130,6 +130,7 @@
 
 		var buf bytes.Buffer
 		g := &ObjcGen{
+			Prefix: "Go",
 			Generator: &Generator{
 				Printer: &Printer{Buf: &buf, IndentEach: []byte("\t")},
 				Fset:    fset,
@@ -441,9 +442,12 @@
 
 func TestCustomPrefix(t *testing.T) {
 	const datafile = "testdata/customprefix.go"
-	const isHeader = true
 	pkg := typeCheck(t, datafile, "")
 
+	type testCase struct {
+		golden string
+		gen    func(w io.Writer) error
+	}
 	var buf bytes.Buffer
 	jg := &JavaGen{
 		JavaPkg: "com.example",
@@ -455,20 +459,7 @@
 		},
 	}
 	jg.Init(nil)
-	og := &ObjcGen{
-		Prefix: "EX",
-		Generator: &Generator{
-			Printer: &Printer{Buf: &buf, IndentEach: []byte("    ")},
-			Fset:    fset,
-			AllPkg:  []*types.Package{pkg},
-			Pkg:     pkg,
-		},
-	}
-	og.Init(nil)
-	testCases := []struct {
-		golden string
-		gen    func(w io.Writer) error
-	}{
+	testCases := []testCase{
 		{
 			"testdata/customprefix.java.golden",
 			func(w io.Writer) error {
@@ -507,39 +498,53 @@
 				return err
 			},
 		},
-		{
-			"testdata/customprefix.objc.go.h.golden",
-			func(w io.Writer) error {
-				buf.Reset()
-				if err := og.GenGoH(); err != nil {
-					return err
-				}
-				_, err := io.Copy(w, &buf)
-				return err
+	}
+	for _, pref := range []string{"EX", ""} {
+		og := &ObjcGen{
+			Prefix: pref,
+			Generator: &Generator{
+				Printer: &Printer{Buf: &buf, IndentEach: []byte("    ")},
+				Fset:    fset,
+				AllPkg:  []*types.Package{pkg},
+				Pkg:     pkg,
 			},
-		},
-		{
-			"testdata/customprefix.objc.h.golden",
-			func(w io.Writer) error {
-				buf.Reset()
-				if err := og.GenH(); err != nil {
+		}
+		og.Init(nil)
+		testCases = append(testCases, []testCase{
+			{
+				"testdata/customprefix" + pref + ".objc.go.h.golden",
+				func(w io.Writer) error {
+					buf.Reset()
+					if err := og.GenGoH(); err != nil {
+						return err
+					}
+					_, err := io.Copy(w, &buf)
 					return err
-				}
-				_, err := io.Copy(w, &buf)
-				return err
+				},
 			},
-		},
-		{
-			"testdata/customprefix.objc.m.golden",
-			func(w io.Writer) error {
-				buf.Reset()
-				if err := og.GenM(); err != nil {
+			{
+				"testdata/customprefix" + pref + ".objc.h.golden",
+				func(w io.Writer) error {
+					buf.Reset()
+					if err := og.GenH(); err != nil {
+						return err
+					}
+					_, err := io.Copy(w, &buf)
 					return err
-				}
-				_, err := io.Copy(w, &buf)
-				return err
+				},
 			},
-		},
+			{
+				"testdata/customprefix" + pref + ".objc.m.golden",
+				func(w io.Writer) error {
+					buf.Reset()
+					if err := og.GenM(); err != nil {
+						return err
+					}
+					_, err := io.Copy(w, &buf)
+					return err
+				},
+			},
+		}...)
 	}
 
 	for _, tc := range testCases {
diff --git a/bind/genobjc.go b/bind/genobjc.go
index a27302a..94a8835 100644
--- a/bind/genobjc.go
+++ b/bind/genobjc.go
@@ -89,9 +89,6 @@
 		return "GoUniverse"
 	}
 	p := g.Prefix
-	if p == "" {
-		p = "Go"
-	}
 	return p + strings.Title(pkg.Name())
 }
 
@@ -140,12 +137,12 @@
 	for _, m := range g.modules {
 		g.Printf("@import %s;\n", m)
 	}
-	g.Printf("#include \"GoUniverse.h\"\n\n")
+	g.Printf("#include \"GoUniverse.objc.h\"\n\n")
 
 	if g.Pkg != nil {
 		for _, pkg := range g.Pkg.Imports() {
 			if g.validPkg(pkg) {
-				g.Printf("#include %q\n", g.namePrefixOf(pkg)+".h")
+				g.Printf("#include %q\n", g.namePrefixOf(pkg)+".objc.h")
 			}
 		}
 	}
@@ -239,8 +236,8 @@
 
 func (g *ObjcGen) gobindOpts() string {
 	opts := []string{"-lang=objc"}
-	if g.Prefix != "" {
-		opts = append(opts, "-prefix="+g.Prefix)
+	if g.Prefix != "Go" {
+		opts = append(opts, fmt.Sprintf("-prefix=%q", g.Prefix))
 	}
 	return strings.Join(opts, " ")
 }
@@ -254,7 +251,7 @@
 	g.Printf("#include <Foundation/Foundation.h>\n")
 	g.Printf("#include \"seq.h\"\n")
 	g.Printf("#include \"_cgo_export.h\"\n")
-	g.Printf("#include %q\n", g.namePrefix+".h")
+	g.Printf("#include %q\n", g.namePrefix+".objc.h")
 	g.Printf("\n")
 
 	// struct
diff --git a/bind/objc/seq.h b/bind/objc/seq.h
index 6dfc334..2227f06 100644
--- a/bind/objc/seq.h
+++ b/bind/objc/seq.h
@@ -7,7 +7,7 @@
 
 #include <Foundation/Foundation.h>
 #include "ref.h"
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 #ifdef DEBUG
 #define LOG_DEBUG(...) NSLog(__VA_ARGS__);
diff --git a/bind/testdata/basictypes.objc.h.golden b/bind/testdata/basictypes.objc.h.golden
index fc13cb1..3841d37 100644
--- a/bind/testdata/basictypes.objc.h.golden
+++ b/bind/testdata/basictypes.objc.h.golden
@@ -7,7 +7,7 @@
 #define __GoBasictypes_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
 FOUNDATION_EXPORT const BOOL GoBasictypesABool;
diff --git a/bind/testdata/basictypes.objc.m.golden b/bind/testdata/basictypes.objc.m.golden
index 3dbe443..a4ca6c3 100644
--- a/bind/testdata/basictypes.objc.m.golden
+++ b/bind/testdata/basictypes.objc.m.golden
@@ -6,7 +6,7 @@
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "GoBasictypes.h"
+#include "GoBasictypes.objc.h"
 
 const BOOL GoBasictypesABool = YES;
 const double GoBasictypesAFloat = 0.2015;
diff --git a/bind/testdata/customprefix.objc.go.h.golden b/bind/testdata/customprefix.objc.go.h.golden
index 5fee907..1fe50ab 100644
--- a/bind/testdata/customprefix.objc.go.h.golden
+++ b/bind/testdata/customprefix.objc.go.h.golden
@@ -1,5 +1,5 @@
 // Objective-C API for talking to customprefix Go package.
-//   gobind -lang=objc -prefix=EX customprefix
+//   gobind -lang=objc -prefix="" customprefix
 //
 // File is generated by gobind. Do not edit.
 
diff --git a/bind/testdata/customprefix.objc.h.golden b/bind/testdata/customprefix.objc.h.golden
index 127d55e..c1602b7 100644
--- a/bind/testdata/customprefix.objc.h.golden
+++ b/bind/testdata/customprefix.objc.h.golden
@@ -1,15 +1,15 @@
 // Objective-C API for talking to customprefix Go package.
-//   gobind -lang=objc -prefix=EX customprefix
+//   gobind -lang=objc -prefix="" customprefix
 //
 // File is generated by gobind. Do not edit.
 
-#ifndef __EXCustomprefix_H__
-#define __EXCustomprefix_H__
+#ifndef __Customprefix_H__
+#define __Customprefix_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
-FOUNDATION_EXPORT void EXCustomprefixF();
+FOUNDATION_EXPORT void CustomprefixF();
 
 #endif
diff --git a/bind/testdata/customprefix.objc.m.golden b/bind/testdata/customprefix.objc.m.golden
index 4e4883d..e4999c5 100644
--- a/bind/testdata/customprefix.objc.m.golden
+++ b/bind/testdata/customprefix.objc.m.golden
@@ -1,15 +1,15 @@
 // Objective-C API for talking to customprefix Go package.
-//   gobind -lang=objc -prefix=EX customprefix
+//   gobind -lang=objc -prefix="" customprefix
 //
 // File is generated by gobind. Do not edit.
 
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "EXCustomprefix.h"
+#include "Customprefix.objc.h"
 
 
-void EXCustomprefixF() {
+void CustomprefixF() {
     proxycustomprefix__F();
 }
 
diff --git a/bind/testdata/customprefixEX.objc.go.h.golden b/bind/testdata/customprefixEX.objc.go.h.golden
new file mode 100644
index 0000000..9da6551
--- /dev/null
+++ b/bind/testdata/customprefixEX.objc.go.h.golden
@@ -0,0 +1,11 @@
+// Objective-C API for talking to customprefix Go package.
+//   gobind -lang=objc -prefix="EX" customprefix
+//
+// File is generated by gobind. Do not edit.
+
+#ifndef __customprefix_H__
+#define __customprefix_H__
+
+#include <stdint.h>
+#include <objc/objc.h>
+#endif
diff --git a/bind/testdata/customprefixEX.objc.h.golden b/bind/testdata/customprefixEX.objc.h.golden
new file mode 100644
index 0000000..80b0be4
--- /dev/null
+++ b/bind/testdata/customprefixEX.objc.h.golden
@@ -0,0 +1,15 @@
+// Objective-C API for talking to customprefix Go package.
+//   gobind -lang=objc -prefix="EX" customprefix
+//
+// File is generated by gobind. Do not edit.
+
+#ifndef __EXCustomprefix_H__
+#define __EXCustomprefix_H__
+
+@import Foundation;
+#include "GoUniverse.objc.h"
+
+
+FOUNDATION_EXPORT void EXCustomprefixF();
+
+#endif
diff --git a/bind/testdata/customprefixEX.objc.m.golden b/bind/testdata/customprefixEX.objc.m.golden
new file mode 100644
index 0000000..90c7f28
--- /dev/null
+++ b/bind/testdata/customprefixEX.objc.m.golden
@@ -0,0 +1,18 @@
+// Objective-C API for talking to customprefix Go package.
+//   gobind -lang=objc -prefix="EX" customprefix
+//
+// File is generated by gobind. Do not edit.
+
+#include <Foundation/Foundation.h>
+#include "seq.h"
+#include "_cgo_export.h"
+#include "EXCustomprefix.objc.h"
+
+
+void EXCustomprefixF() {
+    proxycustomprefix__F();
+}
+
+__attribute__((constructor)) static void init() {
+    init_seq();
+}
diff --git a/bind/testdata/ignore.objc.h.golden b/bind/testdata/ignore.objc.h.golden
index 8c680ab..a7a30bb 100644
--- a/bind/testdata/ignore.objc.h.golden
+++ b/bind/testdata/ignore.objc.h.golden
@@ -7,7 +7,7 @@
 #define __GoIgnore_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
 @class GoIgnoreS;
diff --git a/bind/testdata/ignore.objc.m.golden b/bind/testdata/ignore.objc.m.golden
index 01eb28b..a9bb4ee 100644
--- a/bind/testdata/ignore.objc.m.golden
+++ b/bind/testdata/ignore.objc.m.golden
@@ -6,7 +6,7 @@
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "GoIgnore.h"
+#include "GoIgnore.objc.h"
 
 
 @implementation GoIgnoreS {
diff --git a/bind/testdata/interfaces.objc.h.golden b/bind/testdata/interfaces.objc.h.golden
index e876cee..0001d15 100644
--- a/bind/testdata/interfaces.objc.h.golden
+++ b/bind/testdata/interfaces.objc.h.golden
@@ -7,7 +7,7 @@
 #define __GoInterfaces_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
 @protocol GoInterfacesError;
diff --git a/bind/testdata/interfaces.objc.m.golden b/bind/testdata/interfaces.objc.m.golden
index 82a859a..aaf04cd 100644
--- a/bind/testdata/interfaces.objc.m.golden
+++ b/bind/testdata/interfaces.objc.m.golden
@@ -6,7 +6,7 @@
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "GoInterfaces.h"
+#include "GoInterfaces.objc.h"
 
 @implementation GoInterfacesError {
 }
diff --git a/bind/testdata/issue10788.objc.h.golden b/bind/testdata/issue10788.objc.h.golden
index 9c020ad..24790ca 100644
--- a/bind/testdata/issue10788.objc.h.golden
+++ b/bind/testdata/issue10788.objc.h.golden
@@ -7,7 +7,7 @@
 #define __GoIssue10788_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
 @class GoIssue10788TestStruct;
diff --git a/bind/testdata/issue10788.objc.m.golden b/bind/testdata/issue10788.objc.m.golden
index f10240d..51ea522 100644
--- a/bind/testdata/issue10788.objc.m.golden
+++ b/bind/testdata/issue10788.objc.m.golden
@@ -6,7 +6,7 @@
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "GoIssue10788.h"
+#include "GoIssue10788.objc.h"
 
 
 @implementation GoIssue10788TestStruct {
diff --git a/bind/testdata/issue12328.objc.h.golden b/bind/testdata/issue12328.objc.h.golden
index 39a8b26..ba685ab 100644
--- a/bind/testdata/issue12328.objc.h.golden
+++ b/bind/testdata/issue12328.objc.h.golden
@@ -7,7 +7,7 @@
 #define __GoIssue12328_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
 @class GoIssue12328T;
diff --git a/bind/testdata/issue12328.objc.m.golden b/bind/testdata/issue12328.objc.m.golden
index a617b81..d2248c6 100644
--- a/bind/testdata/issue12328.objc.m.golden
+++ b/bind/testdata/issue12328.objc.m.golden
@@ -6,7 +6,7 @@
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "GoIssue12328.h"
+#include "GoIssue12328.objc.h"
 
 
 @implementation GoIssue12328T {
diff --git a/bind/testdata/issue12403.objc.h.golden b/bind/testdata/issue12403.objc.h.golden
index 3248e1e..46cf656 100644
--- a/bind/testdata/issue12403.objc.h.golden
+++ b/bind/testdata/issue12403.objc.h.golden
@@ -7,7 +7,7 @@
 #define __GoIssue12403_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
 @protocol GoIssue12403Parsable;
diff --git a/bind/testdata/issue12403.objc.m.golden b/bind/testdata/issue12403.objc.m.golden
index ccf7854..5b12b0b 100644
--- a/bind/testdata/issue12403.objc.m.golden
+++ b/bind/testdata/issue12403.objc.m.golden
@@ -6,7 +6,7 @@
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "GoIssue12403.h"
+#include "GoIssue12403.objc.h"
 
 @implementation GoIssue12403Parsable {
 }
diff --git a/bind/testdata/keywords.objc.h.golden b/bind/testdata/keywords.objc.h.golden
index 11b6f95..b3eaab8 100644
--- a/bind/testdata/keywords.objc.h.golden
+++ b/bind/testdata/keywords.objc.h.golden
@@ -7,7 +7,7 @@
 #define __GoKeywords_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
 @protocol GoKeywordsKeywordCaller;
diff --git a/bind/testdata/keywords.objc.m.golden b/bind/testdata/keywords.objc.m.golden
index 2454880..81d7dc8 100644
--- a/bind/testdata/keywords.objc.m.golden
+++ b/bind/testdata/keywords.objc.m.golden
@@ -6,7 +6,7 @@
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "GoKeywords.h"
+#include "GoKeywords.objc.h"
 
 @implementation GoKeywordsKeywordCaller {
 }
diff --git a/bind/testdata/structs.objc.h.golden b/bind/testdata/structs.objc.h.golden
index 6ab4e50..c34888a 100644
--- a/bind/testdata/structs.objc.h.golden
+++ b/bind/testdata/structs.objc.h.golden
@@ -7,7 +7,7 @@
 #define __GoStructs_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
 @class GoStructsS;
diff --git a/bind/testdata/structs.objc.m.golden b/bind/testdata/structs.objc.m.golden
index d5f648c..4cdb057 100644
--- a/bind/testdata/structs.objc.m.golden
+++ b/bind/testdata/structs.objc.m.golden
@@ -6,7 +6,7 @@
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "GoStructs.h"
+#include "GoStructs.objc.h"
 
 
 @implementation GoStructsS {
diff --git a/bind/testdata/try.objc.h.golden b/bind/testdata/try.objc.h.golden
index cfedb08..ba6145c 100644
--- a/bind/testdata/try.objc.h.golden
+++ b/bind/testdata/try.objc.h.golden
@@ -7,7 +7,7 @@
 #define __GoTry_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
 FOUNDATION_EXPORT NSString* GoTryThis();
diff --git a/bind/testdata/try.objc.m.golden b/bind/testdata/try.objc.m.golden
index 0a0c03c..d2b1953 100644
--- a/bind/testdata/try.objc.m.golden
+++ b/bind/testdata/try.objc.m.golden
@@ -6,7 +6,7 @@
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "GoTry.h"
+#include "GoTry.objc.h"
 
 
 NSString* GoTryThis() {
diff --git a/bind/testdata/vars.objc.h.golden b/bind/testdata/vars.objc.h.golden
index ed10da5..178701c 100644
--- a/bind/testdata/vars.objc.h.golden
+++ b/bind/testdata/vars.objc.h.golden
@@ -7,7 +7,7 @@
 #define __GoVars_H__
 
 @import Foundation;
-#include "GoUniverse.h"
+#include "GoUniverse.objc.h"
 
 
 @class GoVarsS;
diff --git a/bind/testdata/vars.objc.m.golden b/bind/testdata/vars.objc.m.golden
index bf689a7..669a2ac 100644
--- a/bind/testdata/vars.objc.m.golden
+++ b/bind/testdata/vars.objc.m.golden
@@ -6,7 +6,7 @@
 #include <Foundation/Foundation.h>
 #include "seq.h"
 #include "_cgo_export.h"
-#include "GoVars.h"
+#include "GoVars.objc.h"
 
 
 @implementation GoVarsS {
diff --git a/cmd/gobind/main.go b/cmd/gobind/main.go
index ef6e808..48d9432 100644
--- a/cmd/gobind/main.go
+++ b/cmd/gobind/main.go
@@ -26,7 +26,7 @@
 	lang          = flag.String("lang", "java", "target language for bindings, either java, go, or objc (experimental).")
 	outdir        = flag.String("outdir", "", "result will be written to the directory instead of stdout.")
 	javaPkg       = flag.String("javapkg", "", "custom Java package path prefix used instead of the default 'go'. Valid only with -lang=java.")
-	prefix        = flag.String("prefix", "", "custom Objective-C name prefix used instead of the default 'Go'. Valid only with -lang=objc.")
+	prefix        = flag.String("prefix", "Go", "custom Objective-C name prefix used instead of the default 'Go'. Valid only with -lang=objc.")
 	bootclasspath = flag.String("bootclasspath", "", "Java bootstrap classpath.")
 	classpath     = flag.String("classpath", "", "Java classpath.")
 )
@@ -40,7 +40,7 @@
 
 	if *lang != "java" && *javaPkg != "" {
 		log.Fatalf("Invalid option -javapkg for gobind -lang=%s", *lang)
-	} else if *lang != "objc" && *prefix != "" {
+	} else if *lang != "objc" && *prefix != "Go" {
 		log.Fatalf("Invalid option -prefix for gobind -lang=%s", *lang)
 	}
 
diff --git a/cmd/gomobile/bind.go b/cmd/gomobile/bind.go
index e7284f4..c07c1a6 100644
--- a/cmd/gomobile/bind.go
+++ b/cmd/gomobile/bind.go
@@ -94,7 +94,7 @@
 	if bindJavaPkg != "" && ctx.GOOS != "android" {
 		return fmt.Errorf("-javapkg is supported only for android target")
 	}
-	if bindPrefix != "" && ctx.GOOS != "darwin" {
+	if bindPrefix != bindPrefixDefault && ctx.GOOS != "darwin" {
 		return fmt.Errorf("-prefix is supported only for ios target")
 	}
 
@@ -146,11 +146,13 @@
 	bindBootClasspath string // -bootclasspath
 )
 
+const bindPrefixDefault = "Go"
+
 func init() {
 	// bind command specific commands.
 	cmdBind.flag.StringVar(&bindJavaPkg, "javapkg", "",
 		"specifies custom Java package path prefix used instead of the default 'go'. Valid only with -target=android.")
-	cmdBind.flag.StringVar(&bindPrefix, "prefix", "",
+	cmdBind.flag.StringVar(&bindPrefix, "prefix", bindPrefixDefault,
 		"custom Objective-C name prefix used instead of the default 'Go'. Valid only with -target=ios.")
 	cmdBind.flag.StringVar(&bindClasspath, "classpath", "", "The classpath for imported Java classes. Valid only with -target=android.")
 	cmdBind.flag.StringVar(&bindBootClasspath, "bootclasspath", "", "The bootstrap classpath for imported Java classes. Valid only with -target=android.")
@@ -188,8 +190,7 @@
 }
 
 func (b *binder) GenObjc(pkg *types.Package, allPkg []*types.Package, outdir string, wrappers []*objc.Named) (string, error) {
-	const bindPrefixDefault = "Go"
-	if bindPrefix == "" || pkg == nil {
+	if pkg == nil {
 		bindPrefix = bindPrefixDefault
 	}
 	pkgName := ""
@@ -202,12 +203,12 @@
 	}
 	bindOption := "-lang=objc"
 	if bindPrefix != bindPrefixDefault {
-		bindOption += " -prefix=" + bindPrefix
+		bindOption += fmt.Sprintf(" -prefix=%q", bindPrefix)
 	}
 
 	fileBase := bindPrefix + strings.Title(pkgName)
 	mfile := filepath.Join(outdir, fileBase+".m")
-	hfile := filepath.Join(outdir, fileBase+".h")
+	hfile := filepath.Join(outdir, fileBase+".objc.h")
 	gohfile := filepath.Join(outdir, pkgName+".h")
 
 	var buf bytes.Buffer
diff --git a/cmd/gomobile/bind_iosapp.go b/cmd/gomobile/bind_iosapp.go
index 3b359e0..4224b06 100644
--- a/cmd/gomobile/bind_iosapp.go
+++ b/cmd/gomobile/bind_iosapp.go
@@ -120,17 +120,17 @@
 		headerFiles[0] = title + ".h"
 		err = copyFile(
 			headers+"/"+title+".h",
-			srcDir+"/"+bindPrefix+title+".h",
+			srcDir+"/"+bindPrefix+title+".objc.h",
 		)
 		if err != nil {
 			return err
 		}
 	} else {
 		for i, fileBase := range fileBases {
-			headerFiles[i] = fileBase + ".h"
+			headerFiles[i] = fileBase + ".objc.h"
 			err = copyFile(
-				headers+"/"+fileBase+".h",
-				srcDir+"/"+fileBase+".h")
+				headers+"/"+fileBase+".objc.h",
+				srcDir+"/"+fileBase+".objc.h")
 			if err != nil {
 				return err
 			}
@@ -226,7 +226,7 @@
 #ifndef __{{.title}}_H__
 #define __{{.title}}_H__
 
-{{range .bases}}#include "{{.}}.h"
+{{range .bases}}#include "{{.}}.objc.h"
 {{end}}
 #endif
 `))