Xcode迅速失败,退出代码254

我得到这个编译器错误在我的代码,我不明白为什么:

<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 

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

 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 } 

(我有更多的案例非常相似,为了简单起见,这些错误不在其中)

第一个错误

一个错误是在行中: animalToSwapWith = false ,如果我将它设置为true,并且除了variables初始化行之外注释掉所有其他错误,错误消失。 另外,如果我将其全部注释掉,但将animalToSwapWith实例化为false,即使该实例没有被实例化为true,也会发生错误。

第二个错误

if (Int(animalViewMatrix.columns) > currentColumn + columnDisplacement)&&(currentColumn + columnDisplacement >= 0)&&(animalViewMatrix.objectAtRow(CInt(currentRow), andColumn: CInt(currentColumn + columnDisplacement)) is AnimalView)在这一行中,所有这些方法都已经在文件的前面被调用过,并且上面有相同types的variables,所以方法的知识应该不重要。

结论

是有原因,为什么这两个错误发生,或者是因为迅速和Xcode 6仍在testing中,这是一个Xcode中的错误? 还要注意的是,当一次一个地注释两个错误时,错误信息是相同的。

这是一个Swift编译器错误,显然,testing两个或多个隐式解包的选项会导致编译器在某些/许多情况下崩溃。 使用Apple的Bugreporter来解决这个问题,将其标记为rdar:// 17212295的重复项。

这是一个最小的例子,崩溃的同一个错误:

 let a: String! let b: String! if a && b { println("have both") } 

在命令行编译如下并见证相同的崩溃:

 $ xcrun swift -v -g crash.swift 

我得到了同样的错误,我追查到这一点:我扩展NSError并在扩展中定义一个enum 。 将enum定义移出扩展可修复错误。

 extension NSError { enum WYBErrorCodes: Int { case Fatal = 1000 case XmlParse = 1100 case CoreData = 1200 } [...] } 

为我的课程采用NSTextViewDelegate协议时遇到同样的错误。 如果我删除该协议,编译进行得很好。 奇怪的确如此。

为了提供其他可能的原因和如何解决这些问题; 我试图在调度块内设置地图视图的区域。 如果我评论了该地区的情况,错误就会消失。

  dispatch_once(&centerMapLocation, { // var theSpan: MKCoordinateSpan = MKCoordinateSpanMake(0.01, 0.01) // var theRegion: MKCoordinateRegion = MKCoordinateRegionMake(manager.location.coordinate, theSpan) // self.map.setRegion(theRegion, animated: true) }) } 

当我尝试扩展NSArray以获得foreach方法时,我遇到了同样的错误:

 extension NSArray { func foreach(f: (AnyObject -> ())) { for elem in self { f(elem) } } } 

这似乎是扩展与function参数func的NSArray将导致相同的问题。 我通过定义一个将NSArray作为参数的forEachInArray函数解决了这个问题:

 func forEachInArray<T>(array: NSArray, f: (AnyObject -> ())) { for elem in array { f(elem) } } 

就我而言,我从桥上快速地调用了一个Objective-C函数。 签名就像 –

  - (SomeReturnType *)getSomething:(SomeOptions *)options success:(void (^)(NSArray *response))success failure:(void (^)(NSError *error))failure; 

从swift,我是这样调用,并得到编译错误为“Xcode快速失败,退出代码254” –

  ObjCClass().getSomething(nil, success: {(response : Array!) in }, failure: {(error: NSError!) in }) 

改变它为以下为我工作 –

  ObjCClass().getSomething(nil, success: {(response : [AnyObject]!) in }, failure: {(error: NSError!) in }) 

我有这个错误,并在今天在线提供的Beta 7中解决了这个错误。