3

I need to remove the reference to some files from my Xcode project from command line. I'm trying with the ruby lib Xcodeproj, but I can't understand how to do it:

proj = Xcodeproj::Project.open(project_file)
proj.targets.each do |target|
    path = "../Pods/MyFolder/Externals/**/*"
    dir = Dir.glob(path).select{ |e| File.file? e }
    dir.each do |file|
        proj.files.delete(file)
    end
end

proj.save

After running the script nothing is changed inside my project.

ChrisH
  • 4,468
  • 2
  • 33
  • 42

1 Answers1

1

I had the same issue. I tried 'reject', 'filter' ... Nothing worked.

The solution that worked was to replace:

proj.files.delete(file)

for

file.remove_from_project
Reimond Hill
  • 4,278
  • 40
  • 52