7300a6e577526aaacca5b6479fba09f9f7be0352
[platform/upstream/grpc.git] / test / cpp / cocoapods / Podfile
1 source 'https://github.com/CocoaPods/Specs.git'
2 platform :ios, '8.0'
3
4 install! 'cocoapods', :deterministic_uuids => false
5
6 # Location of gRPC's repo root relative to this file.
7 GRPC_LOCAL_SRC = '../../..'
8
9 %w(
10   test
11   generic
12 ).each do |target_name|
13   target target_name do
14     pod 'gRPC-Core',      :path => GRPC_LOCAL_SRC
15     pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC
16     pod 'gRPC-C++',       :path => GRPC_LOCAL_SRC
17     pod 'BoringSSL-GRPC',      :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true
18   end
19 end
20
21 # gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's
22 # pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded
23 # and before they are installed in the user project.
24 #
25 # This podspec searches for the gRPC core library headers under "$(PODS_ROOT)/gRPC-Core", where
26 # Cocoapods normally places the downloaded sources. When doing local development of the libraries,
27 # though, Cocoapods just takes the sources from whatever directory was specified using `:path`, and
28 # doesn't copy them under $(PODS_ROOT). When using static libraries, one can sometimes rely on the
29 # symbolic links to the pods headers that Cocoapods creates under "$(PODS_ROOT)/Headers". But those
30 # aren't created when using dynamic frameworks. So our solution is to modify the podspec on the fly
31 # to point at the local directory where the sources are.
32 #
33 # TODO(jcanizales): Send a PR to Cocoapods to get rid of this need.
34 pre_install do |installer|
35   # This is the gRPC-Core podspec object, as initialized by its podspec file.
36   grpc_core_spec = installer.pod_targets.find{|t| t.name == 'gRPC-Core'}.root_spec
37
38   # Copied from gRPC-Core.podspec, except for the adjusted src_root:
39   src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}"
40   grpc_core_spec.pod_target_xcconfig = {
41     'GRPC_SRC_ROOT' => src_root,
42     'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
43     'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
44     # If we don't set these two settings, `include/grpc/support/time.h` and
45     # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
46     # build.
47     'USE_HEADERMAP' => 'NO',
48     'ALWAYS_SEARCH_USER_PATHS' => 'NO',
49   }
50 end
51
52 post_install do |installer|
53   installer.pods_project.targets.each do |target|
54     target.build_configurations.each do |config|
55       config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES'
56     end
57
58     # CocoaPods creates duplicated library targets of gRPC-Core when the test targets include
59     # non-default subspecs of gRPC-Core. All of these library targets start with prefix 'gRPC-Core'
60     # and require the same error suppresion.
61     if target.name.start_with?('gRPC-Core')
62       target.build_configurations.each do |config|
63         # TODO(zyc): Remove this setting after the issue is resolved
64         # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
65         # function" warning
66         config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
67         config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1'
68       end
69     end
70   end
71 end