Skip to content

Instantly share code, notes, and snippets.

@splhack
Created April 19, 2010 08:27
Show Gist options
  • Save splhack/370846 to your computer and use it in GitHub Desktop.
Save splhack/370846 to your computer and use it in GitHub Desktop.
require 'optparse'
require 'pp'
def check(pbxproj, verbose)
plist = NSPropertyListSerialization.propertyListFromData(
NSData.dataWithContentsOfFile(pbxproj),
mutabilityOption:0, format:nil, errorDescription:nil)
objects = plist["objects"]
buildSettings = Hash.new
configs = Hash.new
objects.values.each do |obj|
key = obj["buildConfigurationList"]
if key
productName = obj["productName"] || ""
buildSettings[productName] = Hash.new
list = objects[key]
list["buildConfigurations"].each do |ckey|
config = objects[ckey]
targetName = config["name"]
settings = config["buildSettings"]
buildSettings[productName][targetName] = settings
settings.keys.each do |key|
configs[key] ||= Hash.new
configs[key][targetName] ||= Hash.new
configs[key][targetName][productName] = settings[key]
end
end
end
end
configs.keys.sort.each do |key|
print_line = false
line = "====================\n"
line += key + "\n"
targetSettings = configs[key]
targetSettings.keys.each do |targetName|
productSettings = targetSettings[targetName]
if verbose or productSettings.size > 1
line += " " + targetName + "\n"
line += productSettings.pretty_inspect.gsub(/^(.*)/, ' \1')
print_line = true
end
end
print line if print_line
end
end
@verbose = false
OptionParser.new do |opt|
opt.on('-v') {@verbose = true}
opt.parse!(ARGV)
end
check(ARGV[0], @verbose)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment