Since Xcode 7 and Swift 2.0, I get the error above, like in the screenshot shown here:
I have no idea where this is coming from, cleaning and deleting derived data didn't work.
Anyone else experiencing this problem?
Project settings:
Target settings:
This is what caused the error for me.
Before:
After:
It didn't like it that key was never being used anywhere. I am not sure why it should cause the build to fail though.
In my case i had @objc protocol with optional methods and when i called its methods also in swift class i got that error, after removing the optional keyword from functions in the protocol the error was gone.
before (with error):
after:
To me what caused this error was:
I created a file to create extensions on UIView. Inside this file, I created a private protocol named
Foo
.Then I made:
extension UIView: Foo
Removing the private from the protocol made the error go away.
I guess this is probably a bug. The compiler should warn us about the issue. The same way it warns us we can't add private conformances to types it should tell us that conformance should be using a "public/internal" protocol.
Go to project Build
settings -> Swift Compiler - code generation -> Optimization Level
-> For both Debug & Release select option "Fast,Single-File Optimaiztion[-O]Ok, in my case it was because I had an enum nested in a generic class. Now, the strange thing, is that when I isolated the problem (into the BaseDao2), the compiler told me the right error, but in my real BaseDao implementation (which has more stuff), it throw "trap 6".
When I had this:
Anyway, in my case, I move the DaoError out of the BaseDao and everything compiled. Anyway, my feeling is that "trap 6" is what something cannot compile and the compiler got confused. Starting from a simple case, and adding back what you think might be causing the problem can be helpul to identify the problem by getting the right compile error. In other word, you have to be gentle with the swift compiler.
I didn't try other solutions. I got this problem for this setup:
This line is the source of problem. Defaulting it to a argument seems to not work for a nested function
Solutions are:
FWIW I actually first wrote this in playground and got a different error: