添加 module.modulemap 会导致依赖项循环

Adding module.modulemap causes cycle in dependencies

我有一个静态库,C,其中混合了 obj-c 和 Swift 代码。我的主要应用程序 target A 引用了这个库。项目中还有许多其他依赖项和静态库。由于我将 module.modulemap 文件添加到我的静态库项目中,因此我可以在我的主应用程序的 Swift 代码中使用它,因此项目构建失败并显示以下错误消息:

error: Cycle in dependencies between targets 'A' and 'C'; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources.
Cycle path: A → B → C → A
Cycle details:
→ Target 'A' has target dependency on Target 'B'
→ Target 'B' has compile command for Swift source files
→ Target 'C' has copy command from 'path_to_project/Resources/module.modulemap' to 'path_to_build_folder/Build/Products/Debug-iphonesimulator/include/{ProjectName}/module.modulemap'
○ Target 'C' has compile command with input 'path_to_target_C/{ProjectName}/Somefile.mm'
○ Target 'C' has compile command for Swift source files

这似乎是由于新的 modulemap 文件和我添加到静态库的复制阶段所致,但无法说明为什么该复制阶段会添加依赖循环。

我已按照 swift-static-library-in-objective-c 中提到的步骤添加此支持。

提前致谢。

要解决此问题,您需要转到 Build Phases 并将复制 module.modulemap 的复制阶段移动到 Compile Sources.

上方

但是,仍然不清楚为什么首先会发生依赖关系。

如果完成这项工作后您仍然收到错误消息,将模块从静态库移至静态框架有助于缓解此问题。