gRPC.podspec.template 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # GRPC CocoaPods podspec
  2. # This file has been automatically generated from a template file.
  3. # Please look at the templates directory instead.
  4. # This file can be regenerated from the template by running
  5. # tools/buildgen/generate_projects.sh
  6. # Copyright 2015, Google Inc.
  7. # All rights reserved.
  8. #
  9. # Redistribution and use in source and binary forms, with or without
  10. # modification, are permitted provided that the following conditions are
  11. # met:
  12. #
  13. # * Redistributions of source code must retain the above copyright
  14. # notice, this list of conditions and the following disclaimer.
  15. # * Redistributions in binary form must reproduce the above
  16. # copyright notice, this list of conditions and the following disclaimer
  17. # in the documentation and/or other materials provided with the
  18. # distribution.
  19. # * Neither the name of Google Inc. nor the names of its
  20. # contributors may be used to endorse or promote products derived from
  21. # this software without specific prior written permission.
  22. #
  23. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  26. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  27. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  28. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  29. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  30. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  32. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. <%!
  35. bad_header_names = ('time.h', 'string.h')
  36. def fix_header_name(name):
  37. split_name = name.split('/')
  38. if split_name[-1] in bad_header_names:
  39. return '/'.join(split_name[:-1] + ['grpc_' + split_name[-1]])
  40. else:
  41. return name
  42. %>
  43. Pod::Spec.new do |s|
  44. s.name = 'gRPC'
  45. s.version = '0.6.0'
  46. s.summary = 'gRPC client library for iOS/OSX'
  47. s.homepage = 'http://www.grpc.io'
  48. s.license = 'New BSD'
  49. s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
  50. # s.source = { :git => 'https://github.com/grpc/grpc.git',
  51. # :tag => 'release-0_9_1-objectivec-0.5.1' }
  52. s.ios.deployment_target = '6.0'
  53. s.osx.deployment_target = '10.8'
  54. s.requires_arc = true
  55. # Reactive Extensions library for iOS.
  56. s.subspec 'RxLibrary' do |rs|
  57. rs.source_files = 'src/objective-c/RxLibrary/*.{h,m}',
  58. 'src/objective-c/RxLibrary/transformations/*.{h,m}',
  59. 'src/objective-c/RxLibrary/private/*.{h,m}'
  60. rs.private_header_files = 'src/objective-c/RxLibrary/private/*.h'
  61. end
  62. # Core cross-platform gRPC library, written in C.
  63. s.subspec 'C-Core' do |cs|
  64. cs.source_files = \
  65. % for lib in libs:
  66. % if lib.name in ("grpc", "gpr"):
  67. % for hdr in lib.get("headers", []):
  68. '${fix_header_name(hdr)}', \
  69. % endfor
  70. % for hdr in lib.get("public_headers", []):
  71. '${fix_header_name(hdr)}', \
  72. % endfor
  73. % for src in lib.src:
  74. '${src}', \
  75. % endfor
  76. % endif
  77. % endfor
  78. cs.private_header_files = \
  79. % for lib in libs:
  80. % if lib.name in ("grpc", "gpr"):
  81. % for hdr in lib.get("headers", []):
  82. '${hdr}', \
  83. % endfor
  84. % endif
  85. % endfor
  86. cs.header_mappings_dir = '.'
  87. # The core library includes its headers as either "src/core/..." or "grpc/...", meaning we have
  88. # to tell XCode to look for headers under the "include" subdirectory too.
  89. #
  90. # TODO(jcanizales): Instead of doing this, during installation move everything under
  91. # "include/grpc" one directory up. The directory names under PODS_ROOT are implementation
  92. # details of Cocoapods, and have changed in the past, breaking this podspec.
  93. cs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Private/gRPC" ' +
  94. '"$(PODS_ROOT)/Headers/Private/gRPC/include"' }
  95. cs.requires_arc = false
  96. cs.libraries = 'z'
  97. cs.dependency 'OpenSSL', '~> 1.0.200'
  98. end
  99. # This is a workaround for Cocoapods Issue #1437.
  100. # It renames time.h and string.h to grpc_time.h and grpc_string.h.
  101. # It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run
  102. # prepare_command's of subspecs.
  103. #
  104. # TODO(jcanizales): Try out Todd Reed's solution at Issue #1437.
  105. s.prepare_command = <<-CMD
  106. DIR_TIME="grpc/support"
  107. BAD_TIME="$DIR_TIME/time.h"
  108. GOOD_TIME="$DIR_TIME/grpc_time.h"
  109. grep -rl "$BAD_TIME" include/grpc src/core | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
  110. if [ -f "include/$BAD_TIME" ];
  111. then
  112. mv -f "include/$BAD_TIME" "include/$GOOD_TIME"
  113. fi
  114. DIR_STRING="src/core/support"
  115. BAD_STRING="$DIR_STRING/string.h"
  116. GOOD_STRING="$DIR_STRING/grpc_string.h"
  117. grep -rl "$BAD_STRING" include/grpc src/core | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
  118. if [ -f "$BAD_STRING" ];
  119. then
  120. mv -f "$BAD_STRING" "$GOOD_STRING"
  121. fi
  122. CMD
  123. # Objective-C wrapper around the core gRPC library.
  124. s.subspec 'GRPCClient' do |gs|
  125. gs.source_files = 'src/objective-c/GRPCClient/*.{h,m}',
  126. 'src/objective-c/GRPCClient/private/*.{h,m}'
  127. gs.private_header_files = 'src/objective-c/GRPCClient/private/*.h'
  128. gs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
  129. gs.dependency 'gRPC/C-Core'
  130. # TODO(jcanizales): Remove this when the prepare_command moves everything under "include/grpc"
  131. # one directory up.
  132. gs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Public/gRPC/include"' }
  133. gs.dependency 'gRPC/RxLibrary'
  134. # Certificates, to be able to establish TLS connections:
  135. gs.resource_bundles = { 'gRPC' => ['etc/roots.pem'] }
  136. end
  137. # RPC library for ProtocolBuffers, based on gRPC
  138. s.subspec 'ProtoRPC' do |ps|
  139. ps.source_files = 'src/objective-c/ProtoRPC/*.{h,m}'
  140. ps.dependency 'gRPC/GRPCClient'
  141. ps.dependency 'gRPC/RxLibrary'
  142. ps.dependency 'Protobuf', '~> 3.0.0-alpha-3'
  143. end
  144. end