2016-12-16 77 views
6

從Xcode 8.1更新到8.2後,我在我的項目中遇到了Swift Compiler Error。我正在使用最新的Swift版本和Carthage進行依賴管理。它在Xcode 8.1上工作得很好,現在我已經嘗試了幾個小時來修復它,方法是清理DerivedData和Simulator數據,在Xcode中清理並刪除Build文件夾,但似乎沒有任何幫助。我只安裝了一個Xcode版本。Xcode 8.2,Swift編譯器錯誤:錯誤:意外的輸入文件

我得到以下編譯錯誤:

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 

,它指的是看起來像這樣的文件夾:

folder that cannot be found

它實際上是有那麼我不知道是什麼的線索繼續... 非常感謝幫助! :)

+0

如果將設備設置爲通用iOS設備,它會生成OK嗎? –

+0

不,這是相同的 –

+1

我遇到了同樣的問題,這對我來說是由於搞亂了快捷旗幟造成的。我認爲它一定是在我去除可可足時才引入的,剩下一個-D。 – wayju

回答

7

我有同樣的問題和評論幫助我找出我的問題。

事實上,當出現錯誤或「Other Swift Flag」選項出現錯誤時,會發生此錯誤。在我的情況下,此選項是由我的CI發動機通過空導致錯誤所產生的命令行導致錯誤:

"error: unexpected input file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk" 

回答這個問題,而不是評論可以幫助人們向前伸直:)

+3

我刪除了所有「其他Swift標誌」,「$(繼承)」除外。 最後它運作良好 –

+1

你解決了我的問題。 –

2

在我的情況下,這只是因爲我有一個名爲.Swift的文件(記住首都S!)。我將它正確地重命名爲.swift,並且一切正常。