Last active
December 15, 2022 20:19
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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