自从在Xcode 9(之前的8.2)中打开我的项目以来,一些静态库和框架目标无法编译并出现大量错误。此循环依赖性错误始终位于顶部。
一个例子是libzip的静态库目标。问题源于系统的zlib库的单个#include:
#include <zlib.h>
大多数目标可以通过使用构建设置启用模块(C和Objective-C)来禁用模块来解决此问题。
我有一个定义了几个模块的Swift / C框架,这不是一个解决方案。
许多错误都与tgmath.h
有关,这对于模块的糟糕表现来说有些臭名昭着。我不确定为什么tgmath被包含在内 - 它在Darwin模块图中标记为显式。我很想检查<module-includes>:28
,但我不确定如何。
以下是编译错误的示例。有人知道如何在Xcode 9中解决这个问题吗?
While building module 'zlib' imported from /Users/.../lib/zipint.h:40:
While building module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stddef.h:46:
While building module 'std' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/usr/include/tgmath.h:31:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ctype.h:39:15: fatal error: cyclic dependency in module 'Darwin': Darwin -> std -> Darwin
#include_next <ctype.h>
^
1 error generated.
While building module 'zlib' imported from /Users/.../lib/zipint.h:40:
While building module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stddef.h:46:
In file included from <module-includes>:28:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include/tgmath.h:37:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/usr/include/tgmath.h:31:10: fatal error: could not build module 'std'
#include <complex.h>
~~~~~~~~^
2 errors generated.
While building module 'zlib' imported from /Users/.../lib/zipint.h:40:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/usr/include/zlib.h:34:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/usr/include/zconf.h:247:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stddef.h:46:15: fatal error: could not build module 'Darwin'
#include_next <stddef.h>
~~~~~~~~~~~~~^
3 errors generated.
In file included from /Users/.../lib/zip_get_compression_implementation.c:36:
/Users/.../lib/zipint.h:40:10: fatal error: could not build module 'zlib'
#include <zlib.h>
~~~~~~~~^
4 errors generated.
答案 0 :(得分:4)
最后问题是遗留的自定义标头搜索路径。它明确引用了SDK XcodeDefault.xctoolchain/usr/include/c++/v1
。在搜索路径中包含这些标题会破坏依赖循环保护。