Class: MFXcode::Plugins::Delfileref

Inherits:
Object
  • Object
show all
Defined in:
lib/mfxcode/plugins/delfileref.rb

Overview

Delete files references in the Xcode project

Instance Method Summary collapse

Instance Method Details

#helpObject



27
28
29
30
31
32
33
34
# File 'lib/mfxcode/plugins/delfileref.rb', line 27

def help
  {:short => 'delete files references in the Xcode project',
   :long => <<"END" }
Usage: delfileref project_path file [file file ...]

Delete files references in the project at the given path.
END
end

#run(args) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/mfxcode/plugins/delfileref.rb', line 36

def run(args)
  if args.count >= 2

    project_path = args.shift

    project = Xcodeproj::Project.open(project_path)

    filesToDeleteIfReferenced = args.to_a

    project.files.select { |f| filesToDeleteIfReferenced.include? f.name}.each {|f| f.remove_from_project}

    project.save(project_path)

  else
     puts "Too few arguments"
     puts help[:long]
     
     exit 1
  end

end