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