From 3ce80f6f47b4d59dce536f10237f1d0fd39d6a9b Mon Sep 17 00:00:00 2001 From: Sergey Khliustin Date: Sun, 17 Jul 2022 21:32:22 +0200 Subject: [PATCH 1/2] Update README.md. Added post_install hook snippet for generating Pods.WORKSPACE --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/README.md b/README.md index c5f390a..21a4b7a 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,52 @@ that the `load` statement isn't required in `Pods.WORKSPACE`. _See the [Texture](Examples/Texture) example for a comprehensive example._ +### Private pods and sub-dependencies +You can keep using CocoaPods as a dependency system, download sub-dependencies, and use private pods by adding a small snippet to your post_install hook in Podfile to generate Pods.WORKSPACE +```ruby +post_install do |installer| + puts "Post install" + puts "Generating Pods.WORKSPACE" + development_pods = installer.sandbox.development_pods.keys + # Add some pods here if you want to skip them + skip_pods = [] + mapped_pods = installer.analysis_result.specifications.reduce({}) { |result, spec| + root_spec = spec + unless spec.parent.nil? + root_spec = spec.parent + end + if skip_pods.include? root_spec.name + puts "Skipping #{root_spec.name}" + result + end + url = "Pods/#{root_spec.name}" + if development_pods.include? root_spec.name + url = "." + end + result[root_spec.name] = { + name: root_spec.name, + url: url, + podspec_url: "#{root_spec.defined_in_file.to_s.gsub(/ /, '\ ')}", + generate_header_map: 1 + } + result + } + File.open('Pods.WORKSPACE', 'w') { |file| + mapped_pods.each do |key, value| + new_pod_repository = %{ +new_pod_repository( + name = "#{value[:name]}", + url = "#{value[:url]}", + podspec_url = "#{value[:podspec_url]}", + generate_header_map = 1 +) + } + file.write(new_pod_repository) + end + } +end +``` + ## `new_pod_repository` This macro is the main point of integration for pod dependencies. From d8e09153772514026b2856e3cf2a6ce1c1a1f36e Mon Sep 17 00:00:00 2001 From: Sergey Khliustin Date: Mon, 18 Jul 2022 00:57:09 +0200 Subject: [PATCH 2/2] Fixed code snippet in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21a4b7a..6347bb3 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ post_install do |installer| end if skip_pods.include? root_spec.name puts "Skipping #{root_spec.name}" - result + next result end url = "Pods/#{root_spec.name}" if development_pods.include? root_spec.name