From 226c1c8284dc3ee080c91f7ff62e6431b0b2a74b Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 17 Jan 2017 22:25:53 +0100 Subject: [PATCH] cmd/gomobile: avoid header guard clash in iOS headers 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 --- cmd/gomobile/bind_iosapp.go | 4 ++-- example/bind/ios/bind.xcodeproj/project.pbxproj | 14 ++++++++++++-- example/bind/ios/bind/ViewController.m | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/gomobile/bind_iosapp.go b/cmd/gomobile/bind_iosapp.go index 3f13587..f1baa2d 100644 --- a/cmd/gomobile/bind_iosapp.go +++ b/cmd/gomobile/bind_iosapp.go @@ -223,8 +223,8 @@ var iosBindHeaderTmpl = template.Must(template.New("ios.h").Parse(` {{range .pkgs}}// {{.ImportPath}} {{end}}// // File is generated by gomobile bind. Do not edit. -#ifndef __{{.title}}_H__ -#define __{{.title}}_H__ +#ifndef __{{.title}}_FRAMEWORK_H__ +#define __{{.title}}_FRAMEWORK_H__ {{range .bases}}#include "{{.}}.objc.h" {{end}} diff --git a/example/bind/ios/bind.xcodeproj/project.pbxproj b/example/bind/ios/bind.xcodeproj/project.pbxproj index 8c72342..7a00dd5 100644 --- a/example/bind/ios/bind.xcodeproj/project.pbxproj +++ b/example/bind/ios/bind.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ objects = { /* Begin PBXBuildFile section */ + 64F44A6F1E2D433D009A4747 /* Hello.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 64F44A6E1E2D433D009A4747 /* Hello.framework */; }; EBA3E2861B681AFA00018449 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = EBA3E2851B681AFA00018449 /* main.m */; }; EBA3E2891B681AFA00018449 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EBA3E2881B681AFA00018449 /* AppDelegate.m */; }; EBA3E28C1B681AFA00018449 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EBA3E28B1B681AFA00018449 /* ViewController.m */; }; @@ -20,6 +21,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 64F44A6E1E2D433D009A4747 /* Hello.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Hello.framework; sourceTree = ""; }; EBA3E2801B681AFA00018449 /* bind.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bind.app; sourceTree = BUILT_PRODUCTS_DIR; }; EBA3E2841B681AFA00018449 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; EBA3E2851B681AFA00018449 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -36,6 +38,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 64F44A6F1E2D433D009A4747 /* Hello.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -47,6 +50,7 @@ children = ( EBA3E2821B681AFA00018449 /* bind */, EBA3E2811B681AFA00018449 /* Products */, + 64F44A6E1E2D433D009A4747 /* Hello.framework */, ); sourceTree = ""; }; @@ -264,7 +268,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); INFOPLIST_FILE = bind/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -275,7 +282,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); INFOPLIST_FILE = bind/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/example/bind/ios/bind/ViewController.m b/example/bind/ios/bind/ViewController.m index aacbe7e..db02d92 100644 --- a/example/bind/ios/bind/ViewController.m +++ b/example/bind/ios/bind/ViewController.m @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. #import "ViewController.h" -#import "hello/Hello.h" // Gomobile bind generated header file in hello.framework +@import Hello; // Gomobile bind generated framework @interface ViewController () @end