Skip to content

Instantly share code, notes, and snippets.

@swiftyfinch
Last active June 8, 2024 09:57
Show Gist options
  • Save swiftyfinch/cdfff32dadb007d4eb65ba3d0bdda0c6 to your computer and use it in GitHub Desktop.
Save swiftyfinch/cdfff32dadb007d4eb65ba3d0bdda0c6 to your computer and use it in GitHub Desktop.
Get list of source and resource paths of local pod
#!/usr/bin/ruby
require 'json'
require 'set'
if ARGV.count != 3
abort <<~eos
\e[31m⛔️ Provide arguments:
1) Path to Pods directory
2) Path to pod parent directory
3) Pod name\e[0m
eos
end
PODS_DIRECTORY = ARGV[0].freeze
POD_PARENT_DIRECTORY = ARGV[1].freeze
POD_NAME = ARGV[2].freeze
podspec_json = "#{PODS_DIRECTORY}/Local Podspecs/#{POD_NAME}.podspec.json"
json = JSON.parse(File.read(podspec_json))
glob_paths = Set.new()
source_files = json["source_files"]
if source_files.kind_of?(Array)
glob_paths.merge(source_files)
elsif !source_files.nil?
glob_paths.add(source_files)
end
resource = json["resource"]
glob_paths.add(resource) unless resource.nil?
resources = json["resources"]
glob_paths.merge(resources) unless resources.nil?
resource_bundle = json["resource_bundle"]
glob_paths.merge(resource_bundle.values.flatten) unless resource_bundle.nil?
resource_bundles = json["resource_bundles"]
glob_paths.merge(resource_bundles.values.flatten) unless resource_bundles.nil?
for path in glob_paths
puts Dir.glob("#{POD_PARENT_DIRECTORY}/#{path}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment