From 77bcf03116ee90b8d075e6a1dbd8accb7f9d45e5 Mon Sep 17 00:00:00 2001 From: Ashton-W Date: Mon, 19 Aug 2013 17:28:34 +1000 Subject: [PATCH] Fixed xcdatamodeld current_version not being set correctly Updated spec. --- lib/xcodeproj/project/object/group.rb | 9 +++++---- spec/project/object/group_spec.rb | 6 +----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/xcodeproj/project/object/group.rb b/lib/xcodeproj/project/object/group.rb index d7d79b065..67b799420 100644 --- a/lib/xcodeproj/project/object/group.rb +++ b/lib/xcodeproj/project/object/group.rb @@ -220,14 +220,15 @@ def new_xcdatamodeld(path, sub_group_path = nil) if path.exist? path.children.each do |child_path| if File.extname(child_path) == '.xcdatamodel' - child_ref = ref.new_file_reference(child_path) + child_ref = ref.new_file_reference(File.basename(child_path)) child_ref.source_tree = '' last_child_ref = child_ref elsif File.basename(child_path) == '.xccurrentversion' - xccurrentversion = ref.files.select { |obj| obj.path == Xcodeproj.read_plist(child_path)['_XCCurrentVersionName'] }.first + xccurrentversion = Xcodeproj.read_plist(child_path)['_XCCurrentVersionName'] end end - ref.current_version = xccurrentversion || last_child_ref + ref.current_version = ref.children.select { |obj| obj.path == xccurrentversion }.first if xccurrentversion + ref.current_version = last_child_ref unless xccurrentversion end parent_group = find_subpath(sub_group_path, true) @@ -299,7 +300,7 @@ def new_bundle(product_name) # @return [XCVersionGroup] The new group. # def new_xcdatamodel_group(xcdatamodel_path) - g = @project.new(XCVersionGroup) + g = project.new(XCVersionGroup) g.path = xcdatamodel_path g.version_group_type = 'wrapper.xcdatamodel' file = g.new_file(xcdatamodel_path.sub(/xcdatamodeld$/, 'xcdatamodel')) diff --git a/spec/project/object/group_spec.rb b/spec/project/object/group_spec.rb index d1402df27..2d4832628 100644 --- a/spec/project/object/group_spec.rb +++ b/spec/project/object/group_spec.rb @@ -72,7 +72,7 @@ module ProjectSpecs ref.path.should == 'Model.xcdatamodeld' ref.source_tree.should == '' ref.version_group_type.should == 'wrapper.xcdatamodel' - ref.children.map(&:path).should == ['Model.xcdatamodel', 'Model 2.xcdatamodel'] + ref.children.map{ |x| File.basename(x.path) }.should == ['Model.xcdatamodel', 'Model 2.xcdatamodel'] ref.current_version.isa.should == 'PBXFileReference' ref.current_version.path.should == 'Model 2.xcdatamodel' ref.current_version.last_known_file_type.should == 'wrapper.xcdatamodel' @@ -94,10 +94,6 @@ module ProjectSpecs ref.current_version.path.should.include 'VersionedModel 2.xcdatamodel' ref.current_version.last_known_file_type.should == 'wrapper.xcdatamodel' ref.current_version.source_tree.should == '' - puts "DEBUG: #{ref.debug_children}" - puts "DEBUG: #{ref.debug_plist}" - puts ref.children.to_s - puts ref.current_version.path.to_s @group.children.should.include(ref) end end