Skip to content

Instantly share code, notes, and snippets.

@dnicolson
Last active December 15, 2022 20:19
Show Gist options
  • Save dnicolson/48e535d2ca5a695a1d60747f09ab358f to your computer and use it in GitHub Desktop.
Save dnicolson/48e535d2ca5a695a1d60747f09ab358f to your computer and use it in GitHub Desktop.
Script to find missing files in Xcode .xcodeproj files (they appear red in Xcode 12)
require 'xcodeproj'
project_path = ARGV[0]
project = Xcodeproj::Project.open(project_path)
xcodebuild = `xcodebuild -project '#{project_path}' -showBuildSettings`
build_settings = xcodebuild.scan(/([A-Z_]*) = (.*?)\n/).to_h
missing_files = []
project.files.to_a.each do |file|
absolute_path = file.real_path
build_setting = absolute_path.to_s.match(/\${([A-Z_]*)}/)
if build_setting
absolute_path = absolute_path.to_s.gsub(/\${([A-Z_]*)}/, build_settings[build_setting[1]])
end
missing_files << absolute_path unless File.exist? absolute_path
end
puts "#{missing_files.length} missing files:"
missing_files.each do |f|
puts f
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment