3 # This file has been automatically generated from a template file.
4 # Please make modifications to `templates/gRPC-C++.podspec.template`
5 # instead. This file can be regenerated from the template by running
6 # `tools/buildgen/generate_projects.sh`.
8 # gRPC C++ CocoaPods podspec
10 # Copyright 2017 gRPC authors.
12 # Licensed under the Apache License, Version 2.0 (the "License");
13 # you may not use this file except in compliance with the License.
14 # You may obtain a copy of the License at
16 # http://www.apache.org/licenses/LICENSE-2.0
18 # Unless required by applicable law or agreed to in writing, software
19 # distributed under the License is distributed on an "AS IS" BASIS,
20 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 # See the License for the specific language governing permissions and
22 # limitations under the License.
25 def grpc_lib_files(libs, expect_libs, groups):
28 if lib.name in expect_libs:
30 out += lib.get(group, [])
33 def filter_grpcpp(files):
34 return [file for file in files if not file.startswith("include/grpc++")]
36 def grpc_private_files(libs):
37 out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers", "src"))
40 def grpc_private_headers(libs):
41 out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers",))
44 def grpc_public_headers(libs):
45 out = grpc_lib_files(libs, ("grpc", "gpr"), ("public_headers",))
48 def grpcpp_proto_files(filegroups):
49 out = grpc_lib_files(filegroups, ("grpc++_codegen_proto", "grpc++_config_proto"), ("headers", "src", "public_headers"))
50 excl_files = grpc_lib_files(filegroups, ("grpc++_codegen_base",), ("headers", "src", "public_headers"))
51 out = [file for file in out if file not in excl_files]
52 out = filter_grpcpp(out)
55 def grpcpp_private_files(libs, filegroups):
56 out = grpc_lib_files(libs, ("grpc++",), ("headers", "src"))
57 excl_files = grpc_private_files(libs)
59 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
60 excl_files += grpcpp_proto_files(filegroups)
61 out = [file for file in out if file not in excl_files]
63 # Since some C++ source files directly included private headers in C core, we include all the
64 # C core headers in C++ Implementation subspec as well.
65 out += [file for file in grpc_private_headers(libs) if not file.startswith("third_party/nanopb/")]
67 out = filter_grpcpp(out)
71 def grpcpp_private_headers(libs, filegroups):
72 out = grpc_lib_files(libs, ("grpc++",), ("headers",))
74 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
75 excl_files = grpcpp_proto_files(filegroups)
76 out = [file for file in out if file not in excl_files]
78 # Since some C++ source files directly included private headers in C core, we intentionally
79 # keep the C core headers in \a out. But we should exclude nanopb headers.
80 out = [file for file in out if not file.startswith("third_party/nanopb/")]
82 out = filter_grpcpp(out)
85 def grpcpp_public_headers(libs, filegroups):
86 out = grpc_lib_files(libs, ("grpc++",), ("public_headers",))
87 excl_files = grpc_public_headers(libs)
89 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
90 excl_files += grpcpp_proto_files(filegroups)
92 out = [file for file in out if file not in excl_files]
94 out = filter_grpcpp(out)
98 def grpc_test_util_files(libs):
99 out = grpc_lib_files(libs, ("grpc_test_util",), ("src", "headers"))
102 def grpc_test_util_headers(libs):
103 out = grpc_lib_files(libs, ("grpc_test_util",), ("headers",))
106 # Tests subspec is currently disabled since the tests currently use `grpc++` include style instead of `grpcpp`.
107 # TODO (mxyan): enable Tests subspec after the inclusion style is updated in `test/` directory.
108 def grpcpp_test_util_files(libs, filegroups):
109 out = grpc_lib_files(libs, ("grpc++_test_util",), ("src", "headers"))
110 excl_files = grpc_test_util_files(libs) + grpcpp_private_files(libs, filegroups)
112 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
113 excl_files += grpc_lib_files(filegroups, ("grpc++_codegen_proto", "grpc++_config_proto"), ("headers", "src"))
114 excl_files += ["test/cpp/util/byte_buffer_proto_helper.cc",
115 "test/cpp/util/byte_buffer_proto_helper.h",
116 "test/cpp/end2end/test_service_impl.cc",
117 "test/cpp/end2end/test_service_impl.h"]
118 excl_files += [file for file in out if file.endswith(".proto")]
120 out = [file for file in out if not file in excl_files]
122 # Since some C++ test files directly included private headers in C core, we intentionally add these header
123 # files to this subspec
124 out += grpc_test_util_headers(libs)
128 def ruby_multiline_list(files, indent):
129 return (',\n' + indent*' ').join('\'%s\'' % f for f in files)
131 def modify_podspec_version_string(pod_version, grpc_version):
132 # Append -preX when it is a pre-release
133 if len(str(grpc_version).split('-')) > 1:
134 return pod_version + '-' + str(grpc_version).split('-')[-1]
141 # TODO (mxyan): use version that match gRPC version when pod is stabilized
142 # version = '${settings.version}'
143 version = '${modify_podspec_version_string('0.0.8', settings.version)}'
145 s.summary = 'gRPC C++ library'
146 s.homepage = 'https://grpc.io'
147 s.license = 'Apache License, Version 2.0'
148 s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
150 grpc_version = '${settings.version}'
153 :git => 'https://github.com/grpc/grpc.git',
154 :tag => "v#{grpc_version}",
157 s.ios.deployment_target = '7.0'
158 s.osx.deployment_target = '10.9'
159 s.tvos.deployment_target = '10.0'
161 s.requires_arc = false
164 # Use `grpcpp` as framework name so that `#include <grpcpp/xxx.h>` works when built as
168 # Add include prefix `grpcpp` so that `#include <grpcpp/xxx.h>` works when built as static
172 s.pod_target_xcconfig = {
173 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"',
174 'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"',
175 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"',
176 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
177 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
179 # If we don't set these two settings, `include/grpc/support/time.h` and
180 # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
182 'USE_HEADERMAP' => 'NO',
183 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
188 s.default_subspecs = 'Interface', 'Implementation'
190 # Certificates, to be able to establish TLS connections:
191 s.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] }
193 s.header_mappings_dir = 'include/grpcpp'
195 s.subspec 'Interface' do |ss|
196 ss.header_mappings_dir = 'include/grpcpp'
198 ss.source_files = ${ruby_multiline_list(grpcpp_public_headers(libs, filegroups), 22)}
201 s.subspec 'Implementation' do |ss|
202 ss.header_mappings_dir = '.'
203 ss.dependency "#{s.name}/Interface", version
204 ss.dependency 'gRPC-Core', grpc_version
205 ss.dependency 'nanopb', '~> 0.3'
207 ss.source_files = ${ruby_multiline_list(grpcpp_private_files(libs, filegroups), 22)}
209 ss.private_header_files = ${ruby_multiline_list(grpcpp_private_headers(libs, filegroups), 30)}
212 s.subspec 'Protobuf' do |ss|
213 ss.header_mappings_dir = 'include/grpcpp'
214 ss.dependency "#{s.name}/Interface", version
216 ss.source_files = ${ruby_multiline_list(grpcpp_proto_files(filegroups), 22)}
219 s.prepare_command = <<-END_OF_COMMAND
220 find src/cpp/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include <nanopb/\\1>;g'
221 find src/cpp/ -type f -path '*.grpc_back' -print0 | xargs -0 rm
222 find src/core/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include <nanopb/\\1>;g'
223 find src/core/ -type f -path '*.grpc_back' -print0 | xargs -0 rm