Xcode swift失败,退出代码为254

use*_*687 14 xcode ios swift xcode6 ios8

我在我的代码中收到此编译器错误,我无法弄清楚原因:

<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: swift frontend command failed due to signal (use -v to see invocation)
Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254
Run Code Online (Sandbox Code Playgroud)

错误显示在以下代码段中的某处:

var animalViewToSwap: AnimalView = animalViewMatrix.objectAtRow(0, andColumn: 0) as AnimalView
var currentRow = 0
var currentColumn = 0
var animalToSwapWith = true

var currentLocation = animalViewMatrix.findLocationOfObject(animalView)

currentRow = Int(currentLocation.row) - 1
currentColumn = Int(currentLocation.column) - 1

var rowDisplacement = 0
var columnDisplacement = 0

switch inDirection{

    case "left":
        columnDisplacement = withDistance * -1
        if (Int(animalViewMatrix.columns) > currentColumn + columnDisplacement)&&(currentColumn + columnDisplacement >= 0)&&(animalViewMatrix.objectAtRow(CInt(currentRow), andColumn: CInt(currentColumn + columnDisplacement)) is AnimalView)
        {
            animalToSwapWith = true;
        }
        else { animalToSwapWith = false }

    default:
        println("error")
        animalToSwapWith = false
        break
}
Run Code Online (Sandbox Code Playgroud)

(我有更多的情况非常相似,并且为了简单起见而将它们排除在外 - 错误不在其中)

第一个错误

行中有一个错误:animalToSwapWith = false如果我将其设置为true并在变量初始化行之外注释所有其余部分,则错误消失.此外,如果我将所有内容都注释掉但将animalToSwapWith实例化为false,则会发生错误,即使它实例化为true时也不会发生错误.

第二个错误

该行中存在第二个错误:if (Int(animalViewMatrix.columns) > currentColumn + columnDisplacement)&&(currentColumn + columnDisplacement >= 0)&&(animalViewMatrix.objectAtRow(CInt(currentRow), andColumn: CInt(currentColumn + columnDisplacement)) is AnimalView)在此行中,所有这些方法都已在文件中使用上述相同类型的变量进行调用,因此对方法的了解无关紧要.

结论

是否有原因导致这两个错误发生,或者是因为swift和Xcode-6仍然处于beta测试状态并且它是Xcode中的一个错误?另请注意,当一次一个地将两个错误注释掉时,错误消息是相同的.

Pas*_*cal 17

这是一个Swift编译器错误,显然测试两个或多个隐式解包的选项会导致编译器在某些/许多情况下崩溃.使用Apple的Bugreporter提交此问题,将其标记为rdar:// 17212295的副本.

这是一个与同一错误崩溃的最小示例:

let a: String!
let b: String!

if a && b {
    println("have both")
}
Run Code Online (Sandbox Code Playgroud)

在命令行上编译如下,见证同样的崩溃:

$ xcrun swift -v -g crash.swift
Run Code Online (Sandbox Code Playgroud)


Vit*_*nko 1

当我的类采用 NSTextViewDelegate 协议时,我遇到了同样的错误。如果我删除该协议,编译就会正常。确实很奇怪。