10
votes

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! :)

2
Does it build OK if you set the device to Generic iOS Device? - Matt Le Fleur
No, it is the same - Anders Friis
I had the same issue which for me was caused by messing up the swift flags. I think it must have been introduced when I removed cocopods, leaving a -D. - wayju
Yes, you are absolutely right! I have made the switch to Carthage after using CocoaPods, and when cleaning up my project for Xcode 8.2, I deleted the "COCOAPODS" flag from the "Other Swift Flags". I just tried to add it again and it compiles perfectly! But it doesn't really make any sense that it needs that flag after ditching CocoaPods. Do you know how to get rid of it? - Anders Friis

2 Answers

13
votes

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 :)

4
votes

In my case it was simply because I had a file called .Swift (mind the capital S!). I renamed it correctly to .swift and all went fine.