Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 8.2, Swift Compiler Error: error: unexpected input file

After updating from Xcode 8.1 to 8.2, I am facing a Swift Compiler Error in my project. I am using the latest Swift version and Carthage for dependency management. It worked perfectly fine with Xcode 8.1, and now I have tried for hours to fix it by cleaning DerivedData and Simulator data, cleaning in Xcode and deleting the Build folder but nothing seems to help. I only have one Xcode version installed.

I get the following compile error:

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 

The folder that it is referring to looks like this:

folder that cannot be found

It is actually there so I have no clue about what is going on... Help is much appreciated! :)

like image 832
Anders Friis Avatar asked Dec 16 '16 13:12

Anders Friis


1 Answers

I had the same kind of issue and the comments helped me figure out my problem.

Indeed, this error occurs when there is a typo or an error with the "Other Swift Flag" option. In my case, this option was passed empty by my CI engine causing an error to the generated command line leading to the error :

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

As suggested in the comment, remove all Other Swift Tag except "$(inherited)" and check it works back as expected

Answering the question instead of commenting may help people straight forward :)

like image 63
r4phG Avatar answered Sep 20 '22 20:09

r4phG