Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Package Manager - Unexpected duplicate tasks: Target AppTests (project App) has copy command - SwiftDate

I'm migrating my project from Carthage to SPM. I'm using Xcode 12.0. Building the main app works without any problems but I cannot run my unit tests anymore. I use the same framework SwiftDate v6.2.0 in both my App target (SPMD) and my App test target (SPMDTests).

I already resolved the Swift package product 'your library' is linked as a static library by 'your project' and 'your widget'. This will result in duplication of library code.. I followed the tutorial Swift Package Manager Static Dynamic Xcode Bug.

I can run my app but I cannot run my unit tests. The error says

Unexpected duplicate tasks:
1) Target 'SPMDTests' (project 'SPMD') has copy command from 'xxx/DerivedData/xxx/Build/Products/Debug-iphonesimulator/SwiftDate_SwiftDate.bundle' to 'xxx/DerivedData/xxx/Build/Products/Debug-iphonesimulator/SPMD.app/PlugIns/SPMDTests.xctest/SwiftDate_SwiftDate.bundle'
2) Target 'SPMDTests' (project 'SPMD') has copy command from 'xxx/DerivedData/xxx/Build/Products/Debug-iphonesimulator/SwiftDate_SwiftDate.bundle' to 'xxx/DerivedData/xxx/Build/Products/Debug-iphonesimulator/SPMD.app/PlugIns/SPMDTests.xctest/SwiftDate_SwiftDate.bundle'

1

2

I tried the same setup with Realm and it works without any problems. Is this a bug with SwiftDate or am I missing anything?

like image 947
Yannick Avatar asked Sep 30 '20 01:09

Yannick


1 Answers

There seems to be a bug in the implementation of Swift Packages that include resources in Xcode 12 (also in Xcode 12.2 beta).

This issue will only arise if you have a dependency on a package that has resources (SwiftDate does) in both your main target and your unit test target. This bug only seems to affect compilation of the unit test target, so the main app target should still compile successfully.

like image 82
Eric Yanush Avatar answered Jan 02 '23 07:01

Eric Yanush