Swift package with resources in iOS project won't compile test targets

I'm cross posting this here (I originally posted this in the Apple Developer forums a few days ago), in the hopes of finding someone else who knows more than I, and can either confirm my suspicions, or help find a workaround.

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:

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'

The same diagnostic appears when compiling from the command line using xcodebuild.

Is this something that is expected behaviour here, or is this a bug in the implementation of Swift Packages within Xcode/xcodebuild?

Bump. We're seeing the same issues.

I've filed this as https://bugs.swift.org/browse/SR-13739 and rdar://8802612

I also opened a feedback item (FB8751233) back on September 28th for the issue

Terms of Service

Privacy Policy

Cookie Policy