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'
I tried the same setup with Realm and it works without any problems. Is this a bug with SwiftDate or am I missing anything?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With