问题描述
我正在将我的项目从迦太基迁移到SPM。我正在使用Xcode 12.0。构建主应用程序没有任何问题,但是我不能再运行单元测试了。我在我的App目标(SPMD)和我的App测试目标(SPMDTests)中都使用了相同的框架SwiftDate v6.2.0。
我已经解决了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.
。我遵循了教程Swift Package Manager Static Dynamic Xcode Bug。
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'
我尝试了与 Realm 相同的设置,并且可以正常运行。这是 SwiftDate 的错误,还是我错过了任何东西?
解决方法
在Swift包的实现中似乎存在一个错误,其中包含Xcode 12(也包括Xcode 12.2 beta)中的资源。
仅当您对主要目标和单元测试目标中都具有资源(SwiftDate拥有)的程序包具有依赖性时,才会出现此问题。该错误似乎只影响单元测试目标的编译,因此主应用程序目标仍应成功编译。