Commit 65625da1 authored by Eric Firestone's avatar Eric Firestone

Handle CoreData mapping model resources

When using recursive resource globs, CoreData mapping models should not have their child items added to the project directly.
parent 61c1ae80
......@@ -10,6 +10,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes
* Handle CoreData mapping models with recursive resource globs.
[Eric Firestone](https://github.com/efirestone)
[#4809](https://github.com/CocoaPods/CocoaPods/pull/4809)
* Generate valid xcconfig when target name includes spaces.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#4783](https://github.com/CocoaPods/CocoaPods/issues/4783)
......
......@@ -204,6 +204,9 @@ module Pod
# We add the directory for a Core Data model, but not the items in it.
next if path_str =~ /.*\.xcdatamodeld\/.+/i
# We add the directory for a Core Data migration mapping, but not the items in it.
next if path_str =~ /.*\.xcmappingmodel\/.+/i
# We add the directory for an asset catalog, but not the items in it.
next if path_str =~ /.*\.xcassets\/.+/i
......
......@@ -143,11 +143,32 @@ module Pod
it "doesn't add file references for files within Asset Catalogs" do
@installer.install!
catalog_ref = @installer.pods_project['Pods/BananaLib/Resources/Images.xcassets']
catalog_ref.should.be.not.nil
resources_group_ref = @installer.pods_project['Pods/BananaLib/Resources']
catalog_path = 'Resources/Images.xcassets'
# The asset catalog should be a "PBXFileReference" and therefore doesn't have children.
catalog_ref.is_a?(Xcodeproj::Project::Object::PBXFileReference).should.be.true
resources_group_ref.files.any? { |ref| ref.path == catalog_path }.should.be.true
# The asset catalog should not also be a "PBXGroup".
resources_group_ref.groups.any? { |ref| ref.path == catalog_path }.should.be.false
# None of the children of the catalog directory should be present directly.
resources_group_ref.files.any? { |ref| ref.path.start_with?(catalog_path + '/') }.should.be.false
end
it "doesn't add file references for files within CoreData migration mappings" do
@installer.install!
resources_group_ref = @installer.pods_project['Pods/BananaLib/Resources']
mapping_path = 'Resources/Migration.xcmappingmodel'
# The mapping model should be a "PBXFileReference" and therefore doesn't have children.
resources_group_ref.files.any? { |ref| ref.path == mapping_path }.should.be.true
# The mapping model should not also be a "PBXGroup".
resources_group_ref.groups.any? { |ref| ref.path == mapping_path }.should.be.false
# None of the children of the mapping model directory should be present directly.
resources_group_ref.files.any? { |ref| ref.path.start_with?(mapping_path + '/') }.should.be.false
end
end
......
......@@ -465,6 +465,18 @@ module Pod
end
version_build_file.should.be.nil
end
it 'adds Core Data migration mapping models directly to resources' do
# The model directory item should be present.
dir_build_file = @bundle_target.resources_build_phase.files.find { |bf| bf.file_ref.path == 'Resources/Migration.xcmappingmodel' }
dir_build_file.should.be.not.nil
# An item within the model directory should not be present.
xml_file = @bundle_target.resources_build_phase.files.find do |bf|
bf.file_ref.path =~ %r{Resources/Migration\.xcmappingmodel/.*}i
end
xml_file.should.be.nil
end
end
end
end
......
......@@ -110,6 +110,7 @@ module Pod
@accessor.resources.sort.should == [
@root + 'Resources/Base.lproj',
@root + 'Resources/Images.xcassets',
@root + 'Resources/Migration.xcmappingmodel',
@root + 'Resources/Sample.xcdatamodeld',
@root + 'Resources/de.lproj',
@root + 'Resources/en.lproj',
......@@ -161,6 +162,7 @@ module Pod
@root + 'Resources/de.lproj',
@root + 'Resources/en.lproj',
@root + 'Resources/Images.xcassets',
@root + 'Resources/Migration.xcmappingmodel',
@root + 'Resources/Sample.xcdatamodeld',
@root + 'Resources/sub_dir',
]
......@@ -175,6 +177,7 @@ module Pod
@root + 'Resources/de.lproj',
@root + 'Resources/en.lproj',
@root + 'Resources/Images.xcassets',
@root + 'Resources/Migration.xcmappingmodel',
@root + 'Resources/Sample.xcdatamodeld',
@root + 'Resources/sub_dir',
]
......@@ -189,6 +192,7 @@ module Pod
@root + 'Resources/de.lproj',
@root + 'Resources/en.lproj',
@root + 'Resources/Images.xcassets',
@root + 'Resources/Migration.xcmappingmodel',
@root + 'Resources/Sample.xcdatamodeld',
@root + 'Resources/sub_dir',
]
......
......@@ -26,6 +26,7 @@ module Pod
Resources/Base.lproj/Main.storyboard
Resources/Images.xcassets/Logo.imageset/Contents.json
Resources/Images.xcassets/Logo.imageset/logo.png
Resources/Migration.xcmappingmodel/xcmapping.xml
Resources/Sample.xcdatamodeld/.xccurrentversion
Resources/Sample.xcdatamodeld/Sample\ 2.xcdatamodel/contents
Resources/Sample.xcdatamodeld/Sample.xcdatamodel/contents
......@@ -62,6 +63,7 @@ module Pod
Resources/Base.lproj
Resources/Images.xcassets
Resources/Images.xcassets/Logo.imageset
Resources/Migration.xcmappingmodel
Resources/Sample.xcdatamodeld
Resources/Sample.xcdatamodeld/Sample\ 2.xcdatamodel
Resources/Sample.xcdatamodeld/Sample.xcdatamodel
......@@ -154,6 +156,7 @@ module Pod
paths.sort.should == %w(
Resources/Base.lproj
Resources/Images.xcassets
Resources/Migration.xcmappingmodel
Resources/Sample.xcdatamodeld
Resources/de.lproj
Resources/en.lproj
......
......@@ -44,6 +44,7 @@ module Pod
README
Resources/Base.lproj
Resources/Images.xcassets
Resources/Migration.xcmappingmodel
Resources/Sample.xcdatamodeld
Resources/de.lproj
Resources/en.lproj
......@@ -78,6 +79,7 @@ module Pod
README
Resources/Base.lproj
Resources/Images.xcassets
Resources/Migration.xcmappingmodel
Resources/Sample.xcdatamodeld
Resources/de.lproj
Resources/en.lproj
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment