Permalink
Browse files

Merge pull request #22 from yury/xcversiongroup

Add XCVersionGroup support for xcdatamodeld files. Closes #21
  • Loading branch information...
alloy committed Jul 13, 2012
2 parents a64cbef + 0feeb18 commit 11d8450ba7e8c20fe05f650c2445b462524d99a5
Showing with 34 additions and 0 deletions.
  1. +17 −0 lib/xcodeproj/project/object/group.rb
  2. +17 −0 spec/project/object/group_spec.rb
@@ -92,11 +92,28 @@ def create_group(name)
groups.new("name" => name)
end
+ def version_groups
+ children.list_by_class(XCVersionGroup)
+ end
+
def <<(child)
children << child
end
end
+ class XCVersionGroup < PBXGroup
+
+ attribute :version_group_type
+ attribute :current_version
+
+ def self.new_xcdatamodel_group(project, xcdatamodel_path)
+ group = new(project, nil, 'versionGroupType' => 'wrapper.xcdatamodel')
+ ref = group.files.new('path' => xcdatamodel_path.gsub(/xcdatamodeld$/, 'xcdatamodel'), 'sourceTree' => '<group>', 'lastKnownFileType' => 'wrapper.xcdatamodel')
+ group.current_version = ref.uuid
+ group
+ end
+ end
+
end
end
end
@@ -102,6 +102,23 @@ module ProjectSpecs
@target.source_build_phases.first << file
@group.source_files.should == [file]
end
+
+ it "adds XCVersionGroups" do
+ group = @group.version_groups.new 'versionGroupType' => 'wrapper.xcdatamodel'
+ group.isa.should == 'XCVersionGroup'
+ group.version_group_type.should == 'wrapper.xcdatamodel';
+ end
+ end
+
+ describe "Xcodeproj::Project::Object::XCVersionGroup" do
+ before do
+ @group = @project.groups.new('name' => 'Resources')
+ end
+
+ it "adds xcdatamodel groups" do
+ version_group = @group.version_groups.new_xcdatamodel_group 'Model.xcdatamodeld'
+ version_group.current_version.should == @project.files.last.uuid
+ end
end
end

0 comments on commit 11d8450

Please sign in to comment.