Fix Packages With Expired Signatures to Update Xcode

Failed to update a Mac earlier so I encountered some issues regarding XCode update.

cat /var/log/install.log

This shows the error:

The package "DeveloperTools.pkg" is untrusted. 

This blog post was very helpful but to make your life easy, try this:

cd /App*/Install*/Contents

wget https://raw.github.com/gist/2488097/bb8b3ea3e7b38f3f0dd62cac6cdad89ea0168432/fix_xcode_issues.rb

ruby fix_xcode_issues.rb

Here’s the code:

Dir.glob('Packages/*.pkg') do |pkg_file|
  f = pkg_file.gsub("Packages/", "")
  `sudo pkgutil --expand Packages/#{f} /tmp/#{f} && sudo pkgutil --flatten /tmp/#{f} Packages/#{f}`
  p "#{f} updated"
end

You may have to update the path as needed. It worked well for me.