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

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:
It is actually there so I have no clue about what is going on...
Help is much appreciated! :)

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

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.

Related

Xcode 13.3 Build Failed because of Cycle in Dependencies between targets libsignal-protocol-swift

After updating to Xcode 13.3 facing Build failed issues with libsignal-protocol-swift library.
This is happening while building second time while after cleaning and building for first time it is working fine. Also, Xcode 13.2.1 has no such errors.
Xcode Error as below :
Cycle inside libsignal-protocol-swift iOS; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources.
Cycle details:
→ Target 'libsignal-protocol-swift iOS' has link command with output '/Users/ankitkhanna/Library/Developer/Xcode/DerivedData/BlueSecures-brawgzawheasvqbvhxxglfnlvdlw/Build/Products/Debug-iphoneos/SignalProtocol.framework/SignalProtocol'
○ Target 'libsignal-protocol-swift iOS' has compile command for Swift source files
○ Target 'libsignal-protocol-swift iOS' has copy command from '/Users/ankitkhanna/Documents/Project-Files/Desk-Factors-Project-Files/BlueChats-IOS-master/libsignal-protocol-swift-master/libsignal-protocol-swift/SignalProtocol.h' to '/Users/ankitkhanna/Library/Developer/Xcode/DerivedData/BlueSecures-brawgzawheasvqbvhxxglfnlvdlw/Build/Products/Debug-iphoneos/SignalProtocol.framework/Headers/SignalProtocol.h'
After struggling for sometime the solution was actually the same as mentioned in Xcode suggestions.
i.e. to Move the Headers in project Target -> Build Phases on top Compiled sources.
Drag and move Headers above Compile Sources fixed the error.
Please see the image for reference.
I've faced the same issue after updating to Xcode 13.3; however, in my case, I didn't have Headers in Build Phases.
I've followed these steps to solve it:
Precondition: Xcode must be closed.
Delete the DerivedData folder:
rm -rf ~/Library/Developer/Xcode/DerivedData
In the Terminal, type the following command:
defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1

Strange compiler warning when precompiling prefix.pch

When I want to start my app, I get this:
clang: error: invalid version number in '-mios-simulator-version-min= '
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
What's going on? When I google this error, I'm getting ZERO. This seems to be a very strange failure.
Please apologize, that I can't give more information. It's because I'm completely clueless.
Help!
OK, I've found the solution:
.xcodeproj > General > Deployment Target ----> was empty!
This is not allowed.
Try cleaning your project and/or quitting and relaunching Xcode. I've had various odd problems with Xcode that require one or the other of those things.
In my case there is a space after 8.0 like "8.0 ". When I remove space and re-build error disappears.

Core Plot clang error [duplicate]

I am using CorePlot 0.3, everything was ok until I upgraded XCode to 4.4 (2 days ago), CorePlot failed to build and I got some errors with message:
clang: error: -Z-reserved-lib-stdc++: 'linker' input unused when '-c' is present
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
I have tried to search and it seems there are many people have a same problem, and I also found some suggestions and solution to fix it, I have applied to my CorePlot version but no luck, the issue appear in some classes such as: CPTPlot.m, CPTScatterPlot.m, CPTBarPlot.m, CPTPlotSymbol.m.
I have spending 2 days on this problem but still not able solve it, please help me, thanks in advance.
The latest coreplot will fix your issues with Xcode 4.4 - https://github.com/djw/core-plot
I have not however got those latest changes to work properly in both Xcode 4.4 and Xcode 4.3 so if you are working in teams, different versions, be careful.
I was able to resolve this issue by switching the selected Compiler in Build Options to "LLVM GCC 4.2". It looks like the Validate Settings operation is what is switching the compiler to "Apple LLVM compiler 4.0".

error in compiling .xcdatamodel

i have xcode 4.3 with ios 5.1 and trying to compile and run the project, but it gives error:
Command /Applications/Xcode.app/Contents/Developer/usr/bin/momc failed with exit code 6
i found something in "Data Model Version Compile".. error after upgrading to Lion (Xcode4.1) but it doesn't provide me any suitable solution. It say's to delete unnecessary .xcdatamodel-directories and i did, but i still stuck up there with same issue. Other thing i found that the extension is changed in new xcode its '.xcdatamodeld' instead of '.xcdatamodel'. I copied content content of '.xcdatamodel' file and put in to '.xcdatamodeld' and added to xcode but it gave error at some where else that persistence store might exist. what should i do to run this project..
thanks in advance!!!

Xcode Error When Building

Whenever I compile something in Xcode, I get 3 errors. One is under "Checking dependencies" and says "Unable to create directory /var/folders/zZ/string of letters/more directories/more letters." What is wrong with Xcode/my computer? I switched to the Xcode 4 preview and that works fine, but is not stable. Yes, I have tried restarting. This has been going on for weeks. Thanks for the help.
I had a similar issue, which showed up after switching to xcode 4. The error was:
error: unable to create '/build' (Permission denied)
The solution was to change '/build' to 'build' in the project configuration under Intermediate Build File Path.
In your case I would guess the pch file has a path that starts with '/'.