Project with Swift Package dependencies results in "Unexpected duplicate tasks" error

I've been trying to convert a set of app and library projects to use swift packages for dependencies (previously used Carthage), and I've run into an issue where Xcode is throwing me a diagnostic for "Unexpected duplicate tasks".

The setup:
  • A dynamic library package which includes some file resources (not any special resources like asset catalogs or CoreData models). Let's call this LibA.

  • A second dynamic library, containing test utilities, which depends on LibA. Let's call this one LibB.

  • An iOS app project, where the app target depends on LibA, and the unit test target depends on LibB, and transitively through LibB, depends on LibA.

The result is Xcode will compile the app target, but when compiling the unit test target, fails with the diagnostic:

Code Block
Unexpected duplicate tasks:
1) Target 'TestPMAppTests' (project 'TestPMApp') has copy command from '/Users/someone/Library/Developer/Xcode/DerivedData/TestPMApp-bsobwbvrasoqbtejzhodakcdkqqu/Build/Products/Debug-iphonesimulator/liba_liba.bundle' to '/Users/someone/Library/Developer/Xcode/DerivedData/TestPMApp-bsobwbvrasoqbtejzhodakcdkqqu/Build/Products/Debug-iphonesimulator/TestPMApp.app/PlugIns/TestPMAppTests.xctest/liba_liba.bundle'
2) Target 'TestPMAppTests' (project 'TestPMApp') has copy command from '/Users/someone/Library/Developer/Xcode/DerivedData/TestPMApp-bsobwbvrasoqbtejzhodakcdkqqu/Build/Products/Debug-iphonesimulator/liba_liba.bundle' to '/Users/someone/Library/Developer/Xcode/DerivedData/TestPMApp-bsobwbvrasoqbtejzhodakcdkqqu/Build/Products/Debug-iphonesimulator/TestPMApp.app/PlugIns/TestPMAppTests.xctest/liba_liba.bundle'


Is this something that is expected behaviour here?

I realise this question was 11 months ago, but hopefully you found an answer.

For anyone else who comes across this, there's a ticket with some workarounds and comments: SR-13739

I had this problem as well after a massive merge conflict in my project.pbxproj file.

Turns out the "Compile Sources" step was shown twice in my build phases. Manually editing the project.pbxproj file and checking the PBXNativeTarget section fixed this issue for me: I had to remove the duplicate "Sources"-key there.

Project with Swift Package dependencies results in "Unexpected duplicate tasks" error
 
 
Q