• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1source 'https://github.com/CocoaPods/Specs.git'
2platform :ios, '8.0'
3
4install! 'cocoapods', :deterministic_uuids => false
5
6# Location of gRPC's repo root relative to this file.
7GRPC_LOCAL_SRC = '../../..'
8
9# Install the dependencies in the main target plus all test targets.
10%w(
11  AllTests
12  RxLibraryUnitTests
13  InteropTestsRemote
14  InteropTestsLocalSSL
15  InteropTestsLocalCleartext
16  InteropTestsRemoteWithCronet
17).each do |target_name|
18  target target_name do
19    pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true
20
21    pod '!ProtoCompiler',            :path => "#{GRPC_LOCAL_SRC}/src/objective-c"
22    pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c"
23
24    pod 'BoringSSL-GRPC',       :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true
25
26    pod 'gRPC',           :path => GRPC_LOCAL_SRC
27    pod 'gRPC-Core',      :path => GRPC_LOCAL_SRC
28    pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC
29    pod 'gRPC-ProtoRPC',  :path => GRPC_LOCAL_SRC, :inhibit_warnings => true
30    pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true
31
32    if target_name == 'InteropTestsRemoteWithCronet'
33      pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC
34      pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c"
35    end
36  end
37end
38
39%w(
40  InteropTestsRemoteCFStream
41  InteropTestsLocalSSLCFStream
42  InteropTestsLocalCleartextCFStream
43).each do |target_name|
44  target target_name do
45    pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true
46
47    pod '!ProtoCompiler',            :path => "#{GRPC_LOCAL_SRC}/src/objective-c"
48    pod '!ProtoCompiler-gRPCPlugin', :path => "#{GRPC_LOCAL_SRC}/src/objective-c"
49
50    pod 'BoringSSL-GRPC',                 :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true
51
52    pod 'gRPC/CFStream',             :path => GRPC_LOCAL_SRC
53    pod 'gRPC-Core/CFStream-Implementation',       :path => GRPC_LOCAL_SRC
54    pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC
55    pod 'gRPC-ProtoRPC',  :path => GRPC_LOCAL_SRC, :inhibit_warnings => true
56    pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true
57  end
58end
59
60%w(
61  CoreCronetEnd2EndTests
62  CronetUnitTests
63).each do |target_name|
64  target target_name do
65    pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true
66    pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c"
67    pod 'gRPC-Core', :path => GRPC_LOCAL_SRC
68    pod 'gRPC-Core/Cronet-Interface', :path => GRPC_LOCAL_SRC
69    pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC
70    pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC
71  end
72end
73
74# gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's
75# pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded
76# and before they are installed in the user project.
77#
78# This podspec searches for the gRPC core library headers under "$(PODS_ROOT)/gRPC-Core", where
79# Cocoapods normally places the downloaded sources. When doing local development of the libraries,
80# though, Cocoapods just takes the sources from whatever directory was specified using `:path`, and
81# doesn't copy them under $(PODS_ROOT). When using static libraries, one can sometimes rely on the
82# symbolic links to the pods headers that Cocoapods creates under "$(PODS_ROOT)/Headers". But those
83# aren't created when using dynamic frameworks. So our solution is to modify the podspec on the fly
84# to point at the local directory where the sources are.
85#
86# TODO(jcanizales): Send a PR to Cocoapods to get rid of this need.
87pre_install do |installer|
88  # This is the gRPC-Core podspec object, as initialized by its podspec file.
89  grpc_core_spec = installer.pod_targets.find{|t| t.name.start_with?('gRPC-Core')}.root_spec
90
91  # Copied from gRPC-Core.podspec, except for the adjusted src_root:
92  src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}"
93  grpc_core_spec.pod_target_xcconfig = {
94    'GRPC_SRC_ROOT' => src_root,
95    'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
96    'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
97    # If we don't set these two settings, `include/grpc/support/time.h` and
98    # `src/core/lib/gpr/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
99    # build.
100    'USE_HEADERMAP' => 'NO',
101    'ALWAYS_SEARCH_USER_PATHS' => 'NO',
102  }
103end
104
105post_install do |installer|
106  installer.pods_project.targets.each do |target|
107    target.build_configurations.each do |config|
108      config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES'
109    end
110
111    # CocoaPods creates duplicated library targets of gRPC-Core when the test targets include
112    # non-default subspecs of gRPC-Core. All of these library targets start with prefix 'gRPC-Core'
113    # and require the same error suppresion.
114    if target.name.start_with?('gRPC-Core')
115      target.build_configurations.each do |config|
116        # TODO(zyc): Remove this setting after the issue is resolved
117        # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
118        # function" warning
119        config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
120        if target.name.include?('CFStream')
121          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CFSTREAM=1'
122        else
123          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1'
124        end
125      end
126    end
127
128    # Activate Cronet for the dedicated build configuration 'Cronet', which will be used solely by
129    # the test target 'InteropTestsRemoteWithCronet'
130    # Activate GRPCCall+InternalTests functions for the dedicated build configuration 'Test', which will
131    # be used by all test targets using it.
132    if target.name == 'gRPC' || target.name.start_with?('gRPC.')
133      target.build_configurations.each do |config|
134        if config.name == 'Cronet'
135          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_COMPILE_WITH_CRONET=1 GRPC_TEST_OBJC=1'
136        elsif config.name == 'Test'
137          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_TEST_OBJC=1'
138        end
139      end
140    end
141  end
142end
143