Podfile 5.1 KB

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