从Xcode 8.1更新到8.2后,我在项目中遇到了Swift编译器错误。我正在使用最新的Swift版本和Carthage进行依赖性管理。它在Xcode 8.1上运行良好,现在,我已经尝试了几个小时来修复它,方法是清理DerivedData和Simulator数据,在Xcode中清理并删除Build文件夹,但似乎没有任何帮助。我只安装了一个Xcode版本。

我收到以下编译错误:

CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
cd <ProjectSource>
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk
export TOOLCHAINS=com.apple.dt.toolchain.XcodeDefault

-- all files to compile --

unknown>:0: error: unexpected input file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code

它所指向的文件夹如下所示:

它实际上在那里,所以我对发生的事情一无所知...
非常感谢您的帮助! :)

最佳答案

我遇到了同样的问题,这些评论帮助我弄清楚了我的问题。
确实,当输入错误或“Other Swift Flag”选项出错时,会发生此错误。就我而言,此选项由我的CI引擎传递为空,导致生成的命令行出错并导致错误:

"error: unexpected input file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk"
如评论中所建议,删除除“$(inherited)”以外的所有其他Swift Tag,并检查其是否可以正常工作
回答问题而不是发表评论可能会帮助人们直截了当:)

10-07 19:51
查看更多