I just downloaded the GM release of Xcode 6 and it won\'t compile with this error:
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault
I have the following code showing build error in Release.
if myValue > 5 { myValue = 5.0 }
if myValue < 0 { myValue = 0 }
Adding else
between if statements fixed the issue:
if myValue > 5 { myValue = 5.0 }
else
if myValue < 0 { myValue = 0 }
Demo: https://github.com/exchangegroup/build-error-demo
Xcode Version 6.1 (6A1052d). Builds alright in debug. Submitted ticket to Apple Bug Reporter.
Go to the folder: Users/user/Library/Developer/Xcode/DerivedData
and clear all file,
then then clean and analyze,
It`s work to me.
I see many reasons. My answer is not a generic solution but just adding yet another case that provide to that error. In my case it was setting a button's title like this:
button!.setTitleColor(.whiteColor(), forState: UIControlState.Normal)
instead of this:
button!.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
Just to put this out there: I get this error whenever I put [unowned self]
in a block within a block, like this:
lazy var someVar: SomeType = {
self.successBlock = {[unowned self] in
// ...
}
}()
The solution is to put the [unowned self]
only at the topmost-level block. It seems an unowned reference to self is handled automatically for blocks within blocks.
Of course, I was only able to find this error by first finding out the troublesome file via @Maxwell's answer: https://stackoverflow.com/a/26848000/855680
May be the same issue Swift compile error in XCode 6 GM
I had the same problem, then I use git checkout old versions to find which commit cause the problem, and try to find the key problem code. My key problem code is something like this
func afunc() {
class AClass() {
}
let ac = AClass()
//....
}
Other code could make the same problem, occur in Swift Optimization, and swift compiler doesn't tell you the exact location. This must be a bug by Apple.
Maxwell's solution gives you the closest hint.