【问题标题】:Having trouble compiling yaml.swift for iOS (builds fine for OSX)为 iOS 编译 yaml.swift 时遇到问题(为 OSX 构建良好)
【发布时间】:2015-01-06 22:09:03
【问题描述】:

所以我必须将一些 YML 文件导入到我最新的 swift 项目中,我发现这个可爱的库 (https://github.com/behrang/yaml.swift) 似乎工作得很好。问题是,它是一个 iOS 项目,默认情况下 yaml.swift 为 OSX 编译。

没什么大不了的,我在makefile中更改了这一行

sdk = $$(xcrun --show-sdk-path --sdk macosx)

到这里

sdk = $$(xcrun --show-sdk-path --sdk iphoneos)

一旦我进行此切换,我就会在编译时遇到各种错误。

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/include/mach/ndr.h:37:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/include/mach/ndr.h:37:
#include <libkern/OSByteOrder.h>
         ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/include/libkern/OSByteOrder.h:45:10: error: 'libkern/machine/OSByteOrder.h' file not found
#include <libkern/machine/OSByteOrder.h>
         ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/shims/shims.h:13:10: error: could not build module 'Darwin'
#include <stddef.h>        // for size_t
         ^
<unknown>:0: error: could not build Objective-C module 'SwiftShims'
make: *** [build/libyaml.dylib] Error 1

这是最后几行,但这要追溯到几千行。我找不到的任何东西似乎都与我要编译的库有关。似乎这似乎是 SDK 的问题。我已经尝试挖掘并查看该库是否依赖于 OSX 框架,但它唯一导入的是 Foundation

有什么想法可能与错误有关吗?

到目前为止,我想出的是,SwiftShims 是一个 swift 模块(不是错误所说的 Objective-C)。在 SwiftShims.swift 文件的顶部,它似乎正在导入一些 Darwin/C 模块。也许这就是问题所在?但是 SwiftShims 没有被导入到这个模块的任何 swift 文件中。我真的迷路了,如果能得到任何帮助,我将不胜感激!

【问题讨论】:

  • 您是否尝试过使用iphonesimulator 作为SDK?可能是您没有完整的 iOS SDK。

标签: ios macos swift


【解决方案1】:

您还需要告诉 swift 编译器为运行您的模拟器的 x86 cpu 构建。在make文件中,还需要添加:

-target x86_64-apple-ios8.0

作为 libyml.dylib 部分下的 swiftc 选项之一。

【讨论】:

    猜你喜欢
    • 2014-06-20
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多