From 9b81d9945e80b33815f68499c9809ab934b2a687 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Mon, 12 Oct 2015 19:31:25 -0700 Subject: [PATCH 1/5] =?UTF-8?q?Undo=20Cocoapods=E2=80=99=20bug=20workaroun?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gRPC.podspec | 37 ++++--------------- templates/gRPC.podspec.template | 63 ++++++++++----------------------- 2 files changed, 25 insertions(+), 75 deletions(-) diff --git a/gRPC.podspec b/gRPC.podspec index 69c370e2c0c..a9d544d9263 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '0.11.1' + version = '0.11.2' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'http://www.grpc.io' @@ -46,6 +46,7 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/grpc/grpc.git', :tag => "release-#{version.gsub(/\./, '_')}-objectivec-#{version}" } + s.ios.deployment_target = '7.1' s.osx.deployment_target = '10.9' s.requires_arc = true @@ -66,7 +67,7 @@ Pod::Spec.new do |s| 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/stack_lockfree.h', - 'src/core/support/grpc_string.h', + 'src/core/support/string.h', 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'src/core/support/time_precise.h', @@ -91,7 +92,7 @@ Pod::Spec.new do |s| 'grpc/support/sync_posix.h', 'grpc/support/sync_win32.h', 'grpc/support/thd.h', - 'grpc/support/grpc_time.h', + 'grpc/support/time.h', 'grpc/support/tls.h', 'grpc/support/tls_gcc.h', 'grpc/support/tls_msvc.h', @@ -535,34 +536,10 @@ Pod::Spec.new do |s| # ss.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w' end - # This is a workaround for Cocoapods Issue #1437. - # It renames time.h and string.h to grpc_time.h and grpc_string.h. - # It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run + # Move contents of include/ up a level to avoid manually specifying include paths. + # This needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run # prepare_command's of subspecs. - # - # TODO(jcanizales): Try out others' solutions at Issue #1437. - s.prepare_command = <<-CMD - # Move contents of include up a level to avoid manually specifying include paths - cp -r "include/grpc" "." - - DIR_TIME="grpc/support" - BAD_TIME="$DIR_TIME/time.h" - GOOD_TIME="$DIR_TIME/grpc_time.h" - grep -rl "$BAD_TIME" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g - if [ -f "$BAD_TIME" ]; - then - mv -f "$BAD_TIME" "$GOOD_TIME" - fi - - DIR_STRING="src/core/support" - BAD_STRING="$DIR_STRING/string.h" - GOOD_STRING="$DIR_STRING/grpc_string.h" - grep -rl "$BAD_STRING" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g - if [ -f "$BAD_STRING" ]; - then - mv -f "$BAD_STRING" "$GOOD_STRING" - fi - CMD + s.prepare_command = 'cp -r "include/grpc" "."' # Objective-C wrapper around the core gRPC library. s.subspec 'GRPCClient' do |ss| diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index d1b55adabf9..c0887783e2c 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -5,7 +5,7 @@ # Please look at the templates directory instead. # This file can be regenerated from the template by running # tools/buildgen/generate_projects.sh - + # Copyright 2015, Google Inc. # All rights reserved. # @@ -34,13 +34,10 @@ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + <%! - bad_header_names = ('time.h', 'string.h') def fix_header_name(name): split_name = name.split('/') - if split_name[-1] in bad_header_names: - split_name[-1] = 'grpc_' + split_name[-1] if split_name[0] == 'include': split_name = split_name[1:] return '/'.join(split_name) @@ -63,7 +60,7 @@ %> Pod::Spec.new do |s| s.name = 'gRPC' - version = '0.11.1' + version = '0.11.2' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'http://www.grpc.io' @@ -79,7 +76,7 @@ s.requires_arc = true objc_dir = 'src/objective-c' - + # Reactive Extensions library for iOS. s.subspec 'RxLibrary' do |ss| src_dir = "#{objc_dir}/RxLibrary" @@ -87,71 +84,47 @@ ss.private_header_files = "#{src_dir}/private/*.h" ss.header_mappings_dir = "#{objc_dir}" end - + # Core cross-platform gRPC library, written in C. s.subspec 'C-Core' do |ss| ss.source_files = ${(',\n' + 22*' ').join('\'%s\'' % f for f in grpc_files(libs))} - + ss.private_header_files = ${(',\n' + 30*' ').join('\'%s\'' % f for f in grpc_private_headers(libs))} - + ss.header_mappings_dir = '.' - + ss.requires_arc = false ss.libraries = 'z' ss.dependency 'OpenSSL', '~> 1.0.200' - + # ss.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w' end - - # This is a workaround for Cocoapods Issue #1437. - # It renames time.h and string.h to grpc_time.h and grpc_string.h. - # It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run + + # Move contents of include/ up a level to avoid manually specifying include paths. + # This needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run # prepare_command's of subspecs. - # - # TODO(jcanizales): Try out others' solutions at Issue #1437. - s.prepare_command = <<-CMD - # Move contents of include up a level to avoid manually specifying include paths - cp -r "include/grpc" "." - - DIR_TIME="grpc/support" - BAD_TIME="$DIR_TIME/time.h" - GOOD_TIME="$DIR_TIME/grpc_time.h" - grep -rl "$BAD_TIME" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g - if [ -f "$BAD_TIME" ]; - then - mv -f "$BAD_TIME" "$GOOD_TIME" - fi - - DIR_STRING="src/core/support" - BAD_STRING="$DIR_STRING/string.h" - GOOD_STRING="$DIR_STRING/grpc_string.h" - grep -rl "$BAD_STRING" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g - if [ -f "$BAD_STRING" ]; - then - mv -f "$BAD_STRING" "$GOOD_STRING" - fi - CMD - + s.prepare_command = 'cp -r "include/grpc" "."' + # Objective-C wrapper around the core gRPC library. s.subspec 'GRPCClient' do |ss| src_dir = "#{objc_dir}/GRPCClient" ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}" ss.private_header_files = "#{src_dir}/private/*.h" ss.header_mappings_dir = "#{objc_dir}" - + ss.dependency 'gRPC/C-Core' ss.dependency 'gRPC/RxLibrary' - + # Certificates, to be able to establish TLS connections: ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] } end - + # RPC library for ProtocolBuffers, based on gRPC s.subspec 'ProtoRPC' do |ss| src_dir = "#{objc_dir}/ProtoRPC" ss.source_files = "#{src_dir}/*.{h,m}" ss.header_mappings_dir = "#{objc_dir}" - + ss.dependency 'gRPC/GRPCClient' ss.dependency 'gRPC/RxLibrary' ss.dependency 'Protobuf', '~> 3.0.0-alpha-4' From dc460d28c086a1a2d14036d76f3a94b74131b4bd Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Tue, 13 Oct 2015 13:04:54 -0700 Subject: [PATCH 2/5] Undo moving include/ one dir up, to ease testing workflow. --- gRPC.podspec | 75 ++++++++++++++++----------------- templates/gRPC.podspec.template | 21 +++------ 2 files changed, 42 insertions(+), 54 deletions(-) diff --git a/gRPC.podspec b/gRPC.podspec index a9d544d9263..c056d717c86 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -71,33 +71,33 @@ Pod::Spec.new do |s| 'src/core/support/string_win32.h', 'src/core/support/thd_internal.h', 'src/core/support/time_precise.h', - 'grpc/support/alloc.h', - 'grpc/support/atm.h', - 'grpc/support/atm_gcc_atomic.h', - 'grpc/support/atm_gcc_sync.h', - 'grpc/support/atm_win32.h', - 'grpc/support/cmdline.h', - 'grpc/support/cpu.h', - 'grpc/support/histogram.h', - 'grpc/support/host_port.h', - 'grpc/support/log.h', - 'grpc/support/log_win32.h', - 'grpc/support/port_platform.h', - 'grpc/support/slice.h', - 'grpc/support/slice_buffer.h', - 'grpc/support/string_util.h', - 'grpc/support/subprocess.h', - 'grpc/support/sync.h', - 'grpc/support/sync_generic.h', - 'grpc/support/sync_posix.h', - 'grpc/support/sync_win32.h', - 'grpc/support/thd.h', - 'grpc/support/time.h', - 'grpc/support/tls.h', - 'grpc/support/tls_gcc.h', - 'grpc/support/tls_msvc.h', - 'grpc/support/tls_pthread.h', - 'grpc/support/useful.h', + 'include/grpc/support/alloc.h', + 'include/grpc/support/atm.h', + 'include/grpc/support/atm_gcc_atomic.h', + 'include/grpc/support/atm_gcc_sync.h', + 'include/grpc/support/atm_win32.h', + 'include/grpc/support/cmdline.h', + 'include/grpc/support/cpu.h', + 'include/grpc/support/histogram.h', + 'include/grpc/support/host_port.h', + 'include/grpc/support/log.h', + 'include/grpc/support/log_win32.h', + 'include/grpc/support/port_platform.h', + 'include/grpc/support/slice.h', + 'include/grpc/support/slice_buffer.h', + 'include/grpc/support/string_util.h', + 'include/grpc/support/subprocess.h', + 'include/grpc/support/sync.h', + 'include/grpc/support/sync_generic.h', + 'include/grpc/support/sync_posix.h', + 'include/grpc/support/sync_win32.h', + 'include/grpc/support/thd.h', + 'include/grpc/support/time.h', + 'include/grpc/support/tls.h', + 'include/grpc/support/tls_gcc.h', + 'include/grpc/support/tls_msvc.h', + 'include/grpc/support/tls_pthread.h', + 'include/grpc/support/useful.h', 'src/core/support/alloc.c', 'src/core/support/cmdline.c', 'src/core/support/cpu_iphone.c', @@ -252,13 +252,13 @@ Pod::Spec.new do |s| 'src/core/census/aggregation.h', 'src/core/census/context.h', 'src/core/census/rpc_metric_id.h', - 'grpc/grpc_security.h', - 'grpc/byte_buffer.h', - 'grpc/byte_buffer_reader.h', - 'grpc/compression.h', - 'grpc/grpc.h', - 'grpc/status.h', - 'grpc/census.h', + 'include/grpc/grpc_security.h', + 'include/grpc/byte_buffer.h', + 'include/grpc/byte_buffer_reader.h', + 'include/grpc/compression.h', + 'include/grpc/grpc.h', + 'include/grpc/status.h', + 'include/grpc/census.h', 'src/core/httpcli/httpcli_security_connector.c', 'src/core/security/base64.c', 'src/core/security/client_auth_filter.c', @@ -528,6 +528,8 @@ Pod::Spec.new do |s| 'src/core/census/rpc_metric_id.h' ss.header_mappings_dir = '.' + ss.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Private/gRPC" ' + + '"$(PODS_ROOT)/Headers/Private/gRPC/include"' } ss.requires_arc = false ss.libraries = 'z' @@ -536,11 +538,6 @@ Pod::Spec.new do |s| # ss.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w' end - # Move contents of include/ up a level to avoid manually specifying include paths. - # This needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run - # prepare_command's of subspecs. - s.prepare_command = 'cp -r "include/grpc" "."' - # Objective-C wrapper around the core gRPC library. s.subspec 'GRPCClient' do |ss| src_dir = "#{objc_dir}/GRPCClient" diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index c0887783e2c..e396c411a68 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -36,26 +36,20 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <%! - def fix_header_name(name): - split_name = name.split('/') - if split_name[0] == 'include': - split_name = split_name[1:] - return '/'.join(split_name) - def grpc_files(libs): out = [] for lib in libs: if lib.name in ("grpc", "gpr"): - out.extend(fix_header_name(h) for h in lib.get('headers', [])) - out.extend(fix_header_name(h) for h in lib.get('public_headers', [])) - out.extend(lib.get('src', [])) + out += lib.get('headers', []) + out += lib.get('public_headers', []) + out += lib.get('src', []) return out; def grpc_private_headers(libs): out = [] for lib in libs: if lib.name in ("grpc", "gpr"): - out.extend(lib.get('headers', [])) + out += lib.get('headers', []) return out %> Pod::Spec.new do |s| @@ -92,6 +86,8 @@ ss.private_header_files = ${(',\n' + 30*' ').join('\'%s\'' % f for f in grpc_private_headers(libs))} ss.header_mappings_dir = '.' + ss.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Private/gRPC" ' + + '"$(PODS_ROOT)/Headers/Private/gRPC/include"' } ss.requires_arc = false ss.libraries = 'z' @@ -100,11 +96,6 @@ # ss.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w' end - # Move contents of include/ up a level to avoid manually specifying include paths. - # This needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run - # prepare_command's of subspecs. - s.prepare_command = 'cp -r "include/grpc" "."' - # Objective-C wrapper around the core gRPC library. s.subspec 'GRPCClient' do |ss| src_dir = "#{objc_dir}/GRPCClient" From 208716639db8452fc728ed71dee3581a42e99927 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Tue, 13 Oct 2015 18:12:57 -0700 Subject: [PATCH 3/5] Ignore Objective-C generated files --- .gitignore | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6006619fcbc..7fa2157fa76 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,7 @@ report.xml # port server log portlog.txt -# Xcode +# XCode build/ *.pbxuser !default.pbxuser @@ -58,3 +58,12 @@ DerivedData *.ipa *.xcuserstate *.DS_Store + +# Objective-C generated files +*.pbobjc.* +*.pbrpc.* + +# Cocoapods artifacts +# Podfile.lock and the workspace file are tracked, to ease deleting them. That's +# needed to trigger "pod install" to rerun the preinstall commands. +Pods/ From 2e516e4b0c635f973f7075df2cc0c61ad19ad422 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Tue, 13 Oct 2015 18:36:00 -0700 Subject: [PATCH 4/5] Refer to https://github.com/CocoaPods/CocoaPods/issues/4386 regarding hack. --- gRPC.podspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gRPC.podspec b/gRPC.podspec index c056d717c86..1ee2198125f 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -528,6 +528,8 @@ Pod::Spec.new do |s| 'src/core/census/rpc_metric_id.h' ss.header_mappings_dir = '.' + # This isn't officially supported in Cocoapods. We've asked for an alternative: + # https://github.com/CocoaPods/CocoaPods/issues/4386 ss.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Private/gRPC" ' + '"$(PODS_ROOT)/Headers/Private/gRPC/include"' } From 2bac1f98f935d1358b5b1c84960b22701c0cffa1 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Tue, 13 Oct 2015 19:09:25 -0700 Subject: [PATCH 5/5] The Podspec is a template. The Podspec is a template. The Podspec is a template. --- templates/gRPC.podspec.template | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index e396c411a68..3b96fe28857 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -86,6 +86,8 @@ ss.private_header_files = ${(',\n' + 30*' ').join('\'%s\'' % f for f in grpc_private_headers(libs))} ss.header_mappings_dir = '.' + # This isn't officially supported in Cocoapods. We've asked for an alternative: + # https://github.com/CocoaPods/CocoaPods/issues/4386 ss.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Private/gRPC" ' + '"$(PODS_ROOT)/Headers/Private/gRPC/include"' }