Podfile 6.2 KB

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