In my podspec I have:
...
s.test_spec 'Tests' do |test_spec|
test_spec.source_files = 'Tests/Sources/**/*'
test_spec.resources = 'Tests/Resources/**/*'
end
...
This causes the image I have in the Resources folder to be added to the 'Copy Bundle Resources' build phase, and CocoaPods adds it to the '[CP] Copy Pods Resources' phase. When building this duplicates the file.
Xcode produces this warning:
Showing All Messages
:-1: ignoring duplicated output file: '/Users/michael/Library/Developer/Xcode/DerivedData/MyWorkspace-aeopwxywrxoflbeustfgkzsnmojk/Build/Products/Debug-iphonesimulator/MyTarget.xctest/background.jpg' (in target 'MyTarget')
CocoaPods : 1.5.3
Ruby : ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
RubyGems : 2.5.2.3
Host : Mac OS X 10.13.6 (17G65)
Xcode : 10.0 (10A255)
Git : git version 2.17.1 (Apple Git-112)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : calthings - [email protected]:Calthings/CTPodSpecs.git @ e0244915947e6543c1de4116c6ad4fb72538fd3b
master - https://github.com/CocoaPods/Specs.git @ 7ea1295dbee73cd26cc6f685fa0d4d3a78384a7a
Executable Path: /usr/local/bin/pod
cocoapods-deintegrate : 1.0.2
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk : 1.3.1
cocoapods-try : 1.1.0
Can you please upload a sample app?
From building the sample project I've narrowed down the issue. It only happens when I have a custom scheme which builds the test target and the app in the same build. In the attached project there is a scheme called "All" which generates the issue.
I鈥檓 getting this too, but when I run pod lib lint for a library that has a test spec鈥擨鈥檓 assuming the created project has the same problem as @mozeryansky鈥檚 sample app.
@dnkoutso I attached a sample a while back, should that tag be removed?
done. Most likely a legitimate issue.
@dnkoutso Do you happen to know a workaround for the warnings?
@tinder-hemanthprasad I don't remember exactly, but I attempted to remove the warning by using a resource bundle instead and getting that specific bundle. Or you can just rename one of the assets.
In your podspec, something like:
- test_spec.resources = 'Tests/Resources/**/*'
+ test_spec.resource_bundles = { 'Tests' => 'Tests/Resources/**/*' }
In code:
- let bundle = Bundle(for: type(of: self))
+ let testsBundleURL = Bundle(for: type(of: self)).url(forResource: "Tests", withExtension: "bundle")!
+ let bundle = Bundle(url: testsBundleURL)!
@mozeryansky Moving Resources to a bundle caused the following warning.
Podspec,
test_spec.resource_bundles = { 'Fixtures' => 'Tests/Resources/*' }
Warning:
ignoring duplicated output file: '/Users/<******>/Fixtures.bundle' (in target 'Development-Pod-Unit-Tests')
I did this as workaround,
development_pod_unit_test_targets = installer.pods_project.targets.select {|t| t.name.include? "Unit-Tests" }
def remove_copy_pod_resources_phase(targets)
targets.each { |t| t.resources_build_phase.files.clear }
end
Resources are being copied in both the Copy Bundle Resources and Copy Pods Resources Phases.