From c2d7ecb6993b963cfce103fb7ea3270487e1a58c Mon Sep 17 00:00:00 2001
From: Jorge Canizales <jcanizales@google.com>
Date: Fri, 27 Feb 2015 01:22:41 -0800
Subject: [PATCH] Working podspecs for gRPC core & wrapper

- Moves them to the root of the repo.
- Makes them pass lint (except for the release tag warning).
- Includes the script to rename time.h and string.h in the spec.
- Fixes the #includes in the wrapper files.
---
 RxLibrary.podspec                             | 16 +++++
 gRPC.podspec                                  | 58 +++++++++++++++++++
 src/objective-c/GRPCClient/GRPCCall.m         |  4 +-
 src/objective-c/GRPCClient/GRPCClient.podspec | 14 -----
 .../GRPCClient/private/GRPCChannel.m          |  2 +-
 .../GRPCClient/private/GRPCCompletionQueue.m  |  2 +-
 .../GRPCClient/private/NSData+GRPC.m          |  2 +-
 src/objective-c/RxLibrary/RxLibrary.podspec   | 13 -----
 8 files changed, 79 insertions(+), 32 deletions(-)
 create mode 100644 RxLibrary.podspec
 create mode 100644 gRPC.podspec
 delete mode 100644 src/objective-c/GRPCClient/GRPCClient.podspec
 delete mode 100644 src/objective-c/RxLibrary/RxLibrary.podspec

diff --git a/RxLibrary.podspec b/RxLibrary.podspec
new file mode 100644
index 0000000000..d160f17d73
--- /dev/null
+++ b/RxLibrary.podspec
@@ -0,0 +1,16 @@
+Pod::Spec.new do |s|
+  s.name     = 'RxLibrary'
+  s.version  = '0.0.1'
+  s.summary  = 'Reactive Extensions library for iOS'
+  s.homepage = 'https://github.com/grpc/grpc/tree/master/src/objective-c/RxLibrary'
+  s.license  = 'New BSD'
+  s.authors  = { 'Jorge Canizales' => 'jcanizales@google.com' }
+
+  # s.source = { :git => 'https://github.com/grpc/grpc.git', :tag => 'release-0_5_0' }
+  s.source_files = 'src/objective-c/RxLibrary/*.{h,m}', 'src/objective-c/RxLibrary/transformations/*.{h,m}', 'src/objective-c/RxLibrary/private/*.{h,m}'
+  s.private_header_files = 'src/objective-c/RxLibrary/private/*.h'
+
+  s.platform = :ios
+  s.ios.deployment_target = '6.0'
+  s.requires_arc = true
+end
diff --git a/gRPC.podspec b/gRPC.podspec
new file mode 100644
index 0000000000..4bf1d3515e
--- /dev/null
+++ b/gRPC.podspec
@@ -0,0 +1,58 @@
+Pod::Spec.new do |s|
+  s.name     = 'gRPC'
+  s.version  = '0.0.1'
+  s.summary  = 'Generic gRPC client library for iOS'
+  s.homepage = 'https://www.grpc.io'
+  s.license  = 'New BSD'
+  s.authors  = { 'Jorge Canizales' => 'jcanizales@google.com' }
+
+  # s.source = { :git => 'https://github.com/grpc/grpc.git',  :tag => 'release-0_5_0' }
+  s.source_files = 'src/objective-c/GRPCClient/*.{h,m}', 'src/objective-c/GRPCClient/private/*.{h,m}'
+  s.private_header_files = 'src/objective-c/GRPCClient/private/*.h'
+
+  s.platform = :ios
+  s.ios.deployment_target = '6.0'
+  s.requires_arc = true
+
+  s.subspec 'C-Core' do |cs|
+  	cs.authors = { 'Craig Tiller'   => 'ctiller@google.com',
+  		           'David Klempner' => 'klempner@google.com',
+  		           'Nicolas Noble'  => 'nnoble@google.com',
+                   'Vijay Pai'      => 'vpai@google.com',
+                   'Yang Gao'       => 'yangg@google.com' }
+
+    cs.source_files = 'src/core/**/*.{h,c}', 'include/grpc/*.h', 'include/grpc/**/*.h'
+    cs.private_header_files = 'src/core/**/*.h'
+    cs.header_mappings_dir = '.'
+    cs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Build/gRPC" "$(PODS_ROOT)/Headers/Build/gRPC/include"' }
+
+    cs.requires_arc = false
+    cs.libraries = 'z'
+    cs.dependency 'OpenSSL', '~> 1.0.200'
+  end
+
+  # This is a workaround for Cocoapods Issue #1437.
+  # It renames time.h and string.h to grpc_time.h and grpc_string.h.
+  s.prepare_command = <<-CMD
+    DIR_TIME="grpc/support"
+    BAD_TIME="$DIR_TIME/time.h"
+    GOOD_TIME="$DIR_TIME/grpc_time.h"
+    if [ -f "include/$BAD_TIME" ];
+    then
+      grep -rl "$BAD_TIME" include/grpc src/core | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
+      mv "include/$BAD_TIME" "include/$GOOD_TIME"
+    fi
+
+    DIR_STRING="src/core/support"
+    BAD_STRING="$DIR_STRING/string.h"
+    GOOD_STRING="$DIR_STRING/grpc_string.h"
+    if [ -f "$BAD_STRING" ];
+    then
+      grep -rl "$BAD_STRING" include/grpc src/core | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
+      mv "$BAD_STRING" "$GOOD_STRING"
+    fi
+  CMD
+
+  s.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Public/gRPC/include"' }
+  s.dependency 'RxLibrary', '~> 0.0'
+end
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index f246b81e63..989ce390e2 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -33,8 +33,8 @@
 
 #import "GRPCCall.h"
 
-#include <grpc.h>
-#include <support/time.h>
+#include <grpc/grpc.h>
+#include <grpc/support/grpc_time.h>
 
 #import "GRPCMethodName.h"
 #import "private/GRPCChannel.h"
diff --git a/src/objective-c/GRPCClient/GRPCClient.podspec b/src/objective-c/GRPCClient/GRPCClient.podspec
deleted file mode 100644
index a34c50b54e..0000000000
--- a/src/objective-c/GRPCClient/GRPCClient.podspec
+++ /dev/null
@@ -1,14 +0,0 @@
-Pod::Spec.new do |s|
-  s.name         = 'GRPCClient'
-  s.version      = '0.0.1'
-  s.summary      = 'Generic gRPC client library for iOS'
-  s.author = {
-    'Jorge Canizales' => 'jcanizales@google.com'
-  }
-  s.source_files = '*.{h,m}', 'private/*.{h,m}'
-  s.private_header_files = 'private/*.h'
-  s.platform = :ios
-  s.ios.deployment_target = '6.0'
-  s.requires_arc = true
-  s.dependency 'RxLibrary', '~> 0.0'
-end
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index c8fa69ef91..7ddc01dc24 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -33,7 +33,7 @@
 
 #import "GRPCChannel.h"
 
-#import <grpc.h>
+#import <grpc/grpc.h>
 
 @implementation GRPCChannel
 
diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m
index bc2a824a6b..b98e8ea439 100644
--- a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m
+++ b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m
@@ -33,7 +33,7 @@
 
 #import "GRPCCompletionQueue.h"
 
-#import <grpc.h>
+#import <grpc/grpc.h>
 
 @implementation GRPCCompletionQueue
 
diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.m b/src/objective-c/GRPCClient/private/NSData+GRPC.m
index f885e9db9c..5ab16d9d34 100644
--- a/src/objective-c/GRPCClient/private/NSData+GRPC.m
+++ b/src/objective-c/GRPCClient/private/NSData+GRPC.m
@@ -33,7 +33,7 @@
 
 #import "NSData+GRPC.h"
 
-#include <byte_buffer.h>
+#include <grpc/byte_buffer.h>
 #include <string.h>
 
 // TODO(jcanizales): Move these two incantations to the C library.
diff --git a/src/objective-c/RxLibrary/RxLibrary.podspec b/src/objective-c/RxLibrary/RxLibrary.podspec
deleted file mode 100644
index 605aedaf10..0000000000
--- a/src/objective-c/RxLibrary/RxLibrary.podspec
+++ /dev/null
@@ -1,13 +0,0 @@
-Pod::Spec.new do |s|
-  s.name         = 'RxLibrary'
-  s.version      = '0.0.1'
-  s.summary      = 'Reactive Extensions library for iOS'
-  s.author = {
-    'Jorge Canizales' => 'jcanizales@google.com'
-  }
-  s.source_files = '*.{h,m}', 'transformations/*.{h,m}', 'private/*.{h,m}'
-  s.private_header_files = 'private/*.h'
-  s.platform = :ios
-  s.ios.deployment_target = '6.0'
-  s.requires_arc = true
-end
-- 
GitLab