本文介绍了Xcode 7命令由于信号失败:非法指令4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是使用Xcode 7的迁移工具将项目从Swift 1.2迁移到2.在修复了遗漏的错误等之后,一切都很好,除了一个使我无法构建的错误之外:由于信号而导致命令失败:非法指令4.

I just used Xcode 7's migration tool to migrate a project from Swift 1.2 to 2. After fixing up errors missed and such, all is well except for an error which prevents me from even building: Command failed due to signal: illegal instruction 4.

我已经尝试了这些文章中的帮助(和),虽然这不是我要解决的相同问题,但仍然无法解决该问题.

I have tried the help in these articles (Xcode 7 and Swift 2.0 : Command failed due to signal: Abort trap: 6, and Command failed due to signal: Abort trap: 6) which are not identical issues to mine, but nevertheless they were not able to fix the issue.

我已经清理了构建并删除了派生数据文件夹.我已经安装了最新的CocoaPods,Xcode工具是7.0,我的Swift编译优化是None.还有什么我想念的吗?

I have cleaned the build and removed the derived data folder. I have up to date CocoaPods installation, Xcode tools are at 7.0, and I Swift compile optimization is at None. Is there anything else I'm missing?

谢谢!

推荐答案

因此,在同事的帮助下,找到了答案.我们在构建错误中找到了有问题的文件,但是没有提供任何行.通过消除过程,我们发现这是一行,它是从可选字典内部声明获取JSON字典([String:AnyObject],类型别名为JSONDictionary)的结果的新常量.这是一行:

So an answer was found thanks to the help of a coworker. We found the offending file in the build error, but there was no line provided. Through process of elimination, we found it to be a line that was declaring a new constant to the result of getting a JSON dictionary ([String : AnyObject], typealiased to JSONDictionary), from inside an optional dictionary. Here is the line:

let objectsDictionary = maybeJSON?[key] as? JSONDictionary

将其更改为两个保护声明:

Changed this to two guard statements:

guard let goodJSON = maybeJSON as? JSONDictionary else { return ... }
guard let objectsDictionary = goodJSON[key] as? JSONDictionary else { return ... }

此行在Xcode 6.3.2中起作用,因为它只是提供了一个可选值,但是由于某些原因,Xcode 7中的某些更改不喜欢这样做.我希望这可以帮助遇到此问题的任何其他人.

This line worked in Xcode 6.3.2 as it would just provide an optional value, but for some reason, some change in Xcode 7 didn't like this. I hope this can help anyone else who runs across this.

这篇关于Xcode 7命令由于信号失败:非法指令4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 18:31