Skip to content
Browse files

Add rake task that dumps a Xcode project as YAML.

  • Loading branch information...
1 parent 59baa39 commit 47c2270882f39d44c7d4359b833b73c37fee7034 @alloy committed Nov 7, 2011
Showing with 32 additions and 0 deletions.
  1. +32 −0 Rakefile
View
32 Rakefile
@@ -76,5 +76,37 @@ namespace :spec do
end
end
+desc "Dumps a Xcode project as YAML, meant for diffing"
+task :dump_xcodeproj do
+ require 'yaml'
+ hash = NSDictionary.dictionaryWithContentsOfFile(File.join(ENV['xcodeproj'], 'project.pbxproj'))
+ objects = hash['objects']
+ result = objects.values.map do |object|
+ if children = object['children']
+ object['children'] = children.map do |uuid|
+ child = objects[uuid]
+ child['path'] || child['name']
+ end.sort
+ elsif files = object['files']
+ object['files'] = files.map do |uuid|
+ build_file = objects[uuid]
+ file = objects[build_file['fileRef']]
+ file['path']
+ end
+ elsif file_ref = object['fileRef']
+ file = objects[file_ref]
+ object['file'] = file['path']
+ end
+ object
+ end
+ result.each do |object|
+ object.delete('fileRef')
+ end
+ result = result.sort_by do |object|
+ [object['isa'], object['file'], object['path'], object['name']].compact
+ end
+ puts result.to_yaml
+end
+
desc "Run all specs"
task :spec => 'spec:all'

0 comments on commit 47c2270

Please sign in to comment.
Something went wrong with that request. Please try again.