Skip to content

Instantly share code, notes, and snippets.

@WorldDownTown
Created April 1, 2015 09:01
Show Gist options
  • Save WorldDownTown/dedf3042a65d33073444 to your computer and use it in GitHub Desktop.
Save WorldDownTown/dedf3042a65d33073444 to your computer and use it in GitHub Desktop.
#coding:utf-8
#Xcode上の不要なファイルを抽出するスクリプト
puts "- start class file #{Time.now.strftime("%Y/%m/%d %H:%M:%S")}"
class_waste_count = 0
#クラスファイルの一覧を取得
result = `find ~/SampleProject -type f -name "*.h" -exec basename {} \\; | sort`
class_filenames = result.split("\n")
#クラスファイルの不要なファイルを抽出
class_filenames.each do |class_filename|
command = "grep -rl '#import \"#{class_filename.chomp}\"' ~/SampleProject/* | wc -l"
result = `#{command}`
if result.strip.to_i == 1
puts class_filename
class_waste_count += 1
end
end
puts "- end class file #{Time.now.strftime("%Y/%m/%d %H:%M:%S")}"
puts "- start image file #{Time.now.strftime("%Y/%m/%d %H:%M:%S")}"
image_waste_count = 0
#画像ファイルの一覧を取得
result = `find ~/SampleProject/images -type f -exec basename {} \\; | grep -v '@2x' | sort`
image_filenames = result.split("\n")
#画像ファイルの不要なファイルを抽出
image_filenames.each do |image_filename|
command = "grep -rl '#{image_filename.chomp}' ~/SampleProject/* | grep -vE 'project.pbxproj|xcuserdata' | wc -l"
result = `#{command}`
if result.strip.to_i == 0
puts image_filename
image_waste_count += 1
end
end
puts "- end image file #{Time.now.strftime("%Y/%m/%d %H:%M:%S")}"
puts "class waste count: #{class_waste_count}"
puts "image waste count: #{image_waste_count}"
puts "total: #{class_waste_count + image_waste_count}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment