我是一个跟踪网络速度的小工具的开发者。该代码位于一个使用模块映射的小型框架中,因此我可以在 Swift 中使用 C 代码。
这是我的(旧)模块图:
module PrivateNetwork [system]
{
header "/usr/include/sys/socketvar.h"
header "/usr/include/net/if_dl.h"
header "/usr/include/net/if_types.h"
header "/usr/include/net/if.h"
header "/usr/include/netinet/in.h"
header "/usr/include/netinet/tcp.h"
header "/usr/include/netinet/tcp_var.h"
header "/usr/include/netinet/tcpip.h"
header "/usr/include/netinet/tcp_fsm.h"
header "/usr/include/netinet/ip.h"
header "/usr/include/netinet/ip6.h"
export *
}
切换到 macOS Catalina 后,找不到 /usr/include/ 文件夹,所以我不得不更改它们:
module PrivateNetwork [system]
{
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socketvar.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/ip.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/ip6.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/tcp.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/tcp_fsm.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/tcp_var.h" // > ip.h (in_addr), > tcp.h (tcp_seq)
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/tcpip.h" // > ip.h (in_addr)
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/net/if_types.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/net/if.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/net/if_dl.h"
export *
}
我已经做了一些更改,因为添加完整路径后,模块映射不再编译。我收到以下错误:
Declaration of 'tcp_seq' must be imported from module 'Darwin.POSIX.netinet.tcp' before it is required
完整版:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/tcp_var.h:120:2: Declaration of 'tcp_seq' must be imported from module 'Darwin.POSIX.netinet.tcp' before it is required
。
我不明白这一点,因为定义结构的标头 tcp.h 是在 tcp_var.h 标头之前导入的。
我怎样才能解决这个问题?