Sha256: 4199b2d4c09e6cfd8fbfe8a5a9f50e2fd3714b1da00ba00bc625b563c1de1ab7

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'methadone'
require 'xcodeproj'
require 'findxcprojorphan.rb'

class App
  include Methadone::Main
  include Methadone::CLILogging

  main do |xcproj_path, files_glob|
    proj = Xcodeproj::Project.new(xcproj_path)
    proj.initialize_from_file
    referenced_files = proj.targets.find_all { |target| target.class == Xcodeproj::Project::Object::PBXNativeTarget }.flat_map { |target| target.source_build_phase.files.map(&:file_ref).map(&:real_path).map(&:to_s) }.sort

    files_on_disk = Dir.glob(files_glob).map { |path| File.absolute_path(path) }.sort

    unused_files = files_on_disk - referenced_files

    if unused_files.empty?
      info "No Orphaned Files!"
    else
      info "These files aren't referenced anywhere in the project:"
      unused_files.map { |unused_file| "\t#{unused_file}" }.each { |line| info line }
      exit 1
    end
  end

  description "Find files matching [files_glob] that aren't referenced in [xcproj_path]"

  arg :xcproj_path, 'Path to xcproj to search for orphans'
  arg :files_glob, 'Only files matching this glob will be considered orphans'

  version Findxcprojorphan::VERSION

  use_log_level_option :toggle_debug_on_signal => 'USR1'

  go!
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
findxcprojorphan-1.0.0 bin/findxcprojorphan