Generate more files in gRPC-Core.podspec from build.yaml
diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template
index cb4d556..9785d15 100644
--- a/templates/gRPC-Core.podspec.template
+++ b/templates/gRPC-Core.podspec.template
@@ -22,27 +22,51 @@
   # limitations under the License.
 
   <%!
-  def grpc_private_files(libs):
+  def grpc_lib_files(libs, expect_libs, groups):
     out = []
     for lib in libs:
-      if lib.name in ("grpc", "gpr"):
-        out += lib.get('headers', [])
-        out += lib.get('src', [])
-    return [f for f in out if not f.startswith("third_party/nanopb/")]
+      if lib.name in expect_libs:
+        for group in groups:
+          out += lib.get(group, [])
+    return out
+
+  def grpc_private_files(libs):
+    out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers", "src"))
+    return [file for file in out if not file.startswith("third_party/nanopb/")]
 
   def grpc_public_headers(libs):
-    out = []
-    for lib in libs:
-      if lib.name in ("grpc", "gpr"):
-        out += lib.get('public_headers', [])
+    out = grpc_lib_files(libs, ("grpc", "gpr"), ("public_headers",))
     return out
 
   def grpc_private_headers(libs):
-    out = []
-    for lib in libs:
-      if lib.name in ("grpc", "gpr"):
-        out += lib.get('headers', [])
-    return [f for f in out if not f.startswith("third_party/nanopb/")]
+    out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers",))
+    return [file for file in out if not file.startswith("third_party/nanopb/")]
+
+  def grpc_cronet_files(libs):
+    out = grpc_lib_files(libs, ("grpc_cronet",), ("src", "headers"))
+    excl = grpc_private_files(libs)
+    excl += [
+        # We do not need cronet dedicated plugin registry
+        "src/core/plugin_registry/grpc_cronet_plugin_registry.cc",
+        # We do not need dummy cronet API for ObjC
+        "src/core/ext/transport/cronet/transport/cronet_api_dummy.cc",
+    ]
+    return [file for file in out if not file in excl]
+
+  def grpc_cronet_public_headers(libs):
+    out = grpc_lib_files(libs, ("grpc_cronet",), ("public_headers",))
+    excl = grpc_public_headers(libs)
+    return [file for file in out if not file in excl]
+
+  def grpc_test_util_files(libs):
+    out = grpc_lib_files(libs, ("grpc_test_util", "gpr_test_util"), ("src", "headers"))
+    excl = grpc_private_files(libs)
+    return [file for file in out if not file in excl]
+
+  def end2end_tests_files(libs):
+    out = grpc_lib_files(libs, ("end2end_tests",), ("src", "headers"))
+    excl = grpc_private_files(libs)
+    return [file for file in out if not file in excl]
 
   def ruby_multiline_list(files, indent):
     return (',\n' + indent*' ').join('\'%s\'' % f for f in files)
@@ -153,7 +177,7 @@
 
     s.subspec 'Cronet-Interface' do |ss|
       ss.header_mappings_dir = 'include/grpc'
-      ss.source_files = 'include/grpc/grpc_cronet.h'
+      ss.source_files = ${ruby_multiline_list(grpc_cronet_public_headers(libs), 22)}
     end
 
     s.subspec 'Cronet-Implementation' do |ss|
@@ -163,9 +187,7 @@
       ss.dependency "#{s.name}/Implementation", version
       ss.dependency "#{s.name}/Cronet-Interface", version
 
-      ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc',
-                        'src/core/ext/transport/cronet/transport/cronet_transport.{cc,h}',
-                        'third_party/objective_c/Cronet/bidirectional_stream_c.h'
+      ss.source_files = ${ruby_multiline_list(grpc_cronet_files(libs), 22)}
     end
 
     s.subspec 'Tests' do |ss|
@@ -174,17 +196,8 @@
       ss.dependency "#{s.name}/Interface", version
       ss.dependency "#{s.name}/Implementation", version
 
-      ss.source_files = 'test/core/end2end/cq_verifier.{cc,h}',
-                        'test/core/end2end/end2end_tests.{cc,h}',
-                        'test/core/end2end/end2end_test_utils.cc',
-                        'test/core/end2end/tests/*.{cc,h}',
-                        'test/core/end2end/fixtures/*.h',
-                        'test/core/end2end/data/*.{cc,h}',
-                        'test/core/util/debugger_macros.{cc,h}',
-                        'test/core/util/test_config.{cc,h}',
-                        'test/core/util/port.h',
-                        'test/core/util/port.cc',
-                        'test/core/util/port_server_client.{cc,h}'
+      ss.source_files = ${ruby_multiline_list(grpc_test_util_files(libs), 22)},
+                        ${ruby_multiline_list(end2end_tests_files(libs), 22)}
     end
 
     # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path?