ios 无法执行命令:分段错误:11 swift 前端命令因信号而失败(使用 -v 查看调用)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25007755/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 01:35:56  来源:igfitidea点击:

unable to execute command: Segmentation fault: 11 swift frontend command failed due to signal (use -v to see invocation)

iosxcodesegmentation-faultswift

提问by Salman Hasrat Khan

I have an iOS swift program that compiles and runs fine on Xcode Beta2. When I downloaded beta4, I got a few syntax errors for the new swift language which I corrected. I now get this error:

我有一个 iOS swift 程序,它可以在 Xcode Beta2 上编译并运行良好。当我下载 beta4 时,我纠正了新的 swift 语言的一些语法错误。我现在收到此错误:

<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)

The problem is that it does not tell me where this error is so that I can further troubleshoot it. Where can I type -v in order to "see the invocation" and troubleshoot further? Without this, there is absolute no way to figure out the problem. Thanks in advance.

问题是它没有告诉我这个错误在哪里,以便我可以进一步解决它。我在哪里可以输入 -v 以“查看调用”并进一步排除故障?没有这个,就绝对没有办法找出问题所在。提前致谢。

回答by yndolok

Here's how I was able to find out what the problem was:

以下是我如何找出问题所在:

  1. Click on the issue in the issue navigator (? + 4, then click on the line with the red ! at the start)
  2. At the bottom of the file that appears, there should be a line that says something like:
  1. 单击问题导航器中的问题(?+ 4,然后单击开头带有红色的行!)
  2. 在出现的文件底部,应该有一行内容如下:

1. While emitting IR SIL function @_TToZFC4Down8Resource12getInstancesfMS0_U__FTSS6paramsGVSs10DictionarySSPSs9AnyObject__9onSuccessGSqFGSaQ__T__7onErrorGSqFT5errorCSo7NSError8responseGSqCSo17NSHTTPURLResponse__T___T_ for 'getInstances' at /path/to/file.swift:112:5

1. While emitting IR SIL function @_TToZFC4Down8Resource12getInstancesfMS0_U__FTSS6paramsGVSs10DictionarySSPSs9AnyObject__9onSuccessGSqFGSaQ__T__7onErrorGSqFT5errorCSo7NSError8responseGSqCSo17NSHTTPURLResponse__T___T_ for 'getInstances' at /path/to/file.swift:112:5

  1. The location where your error occurred is at the end of that line. (In this case, on line 112 of file.swift in getInstances).
  1. 发生错误的位置在该行的末尾。(在这种情况下,在 file.swift in 的第 112 行getInstances)。

回答by Manab Kumar Mal

I was trying to add the PayPal framework to my iOS Project (Xcode 7.2 and Objective C language). When building it did not throw any error, but when I tried to archive the Project and make the IPA, I was getting that error

我试图将 PayPal 框架添加到我的 iOS 项目(Xcode 7.2 和 Objective C 语言)。构建它时没有抛出任何错误,但是当我尝试存档项目并制作 IPA 时,我收到了该错误

unable to execute command: Segmentation fault: 11

无法执行命令:分段错误:11

Screenshot:

截屏:

enter image description here

在此处输入图片说明

After struggling for a long time, I disabled the Bitcode in Project's Target > Build Settings > Enable Bitcode. Now the project can be archived. Please check the following screenshot.

在挣扎了很长时间后,我禁用了Project's Target > Build Settings > Enable Bitcode. 现在可以归档项目。请检查以下屏幕截图。

enter image description here

在此处输入图片说明

回答by Jeehut

Can't really give a straight solution on this (although I'm sure it's an Apple bug), but I just came across the exact same error message and happen to solve it. Here's what I did:

无法真正就此给出直接的解决方案(尽管我确定这是 Apple 的错误),但我只是遇到了完全相同的错误消息并碰巧解决了它。这是我所做的:

In General

一般来说

  1. Comment out recently changed Swift code (check commits) until the app compiles again
  2. Command-click each called method in the failing line and check if there could be an ambiguity
  1. 注释掉最近更改的 Swift 代码(检查提交),直到应用再次编译
  2. 按住 Command 键单击失败行中的每个调用方法并检查是否存在歧义

My Example

我的例子

In my case (I was using the XMPPFrameworkwritten in Objective-C) the failing code looked like this:

就我而言(我使用的是用Objective-C 编写的XMPPFramework)失败的代码如下所示:

for roomMessage: XMPPRoomMessage in self.messages {
    let slices = split(roomMessage.nickname(), { 
for roomMessage: XMPPRoomMessageCoreDataStorageObject in self.messages {
    let slices = split(roomMessage.nickname, { 
let globalQueue: NSOperationQueue = {
    let queue = NSOperationQueue()
    queue.suspended = false
    queue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount
    return queue
}()
== "_" }, allowEmptySlices: false) }
== "_" }, allowEmptySlices: false) }

Once I replaced roomMessage.nickname()with "0_test"the code didn't fail any more. So I command-clicked the method nickname()(twice) and here's what I saw:

一旦我roomMessage.nickname()"0_test"代码替换就不再失败了。所以我命令单击该方法nickname()(两次),这是我看到的:

enter image description here

在此处输入图片说明

My guess was that the Swift 1.1 compiler has problems with figuring out which method to call if the exact type of an object is not clear. So I made the type of roomMessageexplicitand got another error which I fixed by removing the braces behind the nickname()method call. This made my app build again.Here's the working code:

我的猜测是,如果对象的确切类型不清楚,Swift 1.1 编译器在确定要调用的方法方面存在问题。因此,我使用了显式类型roomMessage并得到了另一个错误,我通过删除nickname()方法调用后面的大括号来修复该错误。这使我的应用程序再次构建。这是工作代码:

var MYClass : MYClass {
    get {
        return.....
    }
}

I hope this helps someone out there to investigate the issue more quickly than I did.

我希望这可以帮助那里的人比我更快地调查问题。

回答by Ebru Güng?r

I also had the same problem,

我也遇到了同样的问题

  1. when I cleaned the derived data
  2. Remove all removed derived data from Trash as well.
  3. Stop Xcode, restart it and clean build
  1. 当我清理派生数据时
  2. 也从垃圾箱中删除所有已删除的派生数据。
  3. 停止Xcode,重新启动并清理构建

It should be fixed now.

现在应该修复了。

回答by Arthur Gevorkyan

My problem was that I tried to mimic static variables with the so-called module approach (the Module design pattern). So, I had something like that (just a simple static reference to an operation queue declared at the level of a swift file):

我的问题是我试图用所谓的模块方法(模块设计模式)模仿静态变量。所以,我有类似的东西(只是对在 swift 文件级别声明的操作队列的简单静态引用):

var myClass : MYClass {
    get {
        return.....
    }
}

So, that worked fine in Xcode 6.x.x, but ceased to compile in Xcode 7beta. Just want you guys to be aware of it. P.S. In general, I managed to find out what was wrongfrom the logs(see the screenshot attached). Hope this saves you some time.enter image description here

所以,这在 Xcode 6.xx 中运行良好,但在 Xcode 7beta 中停止编译。只是想让你们意识到这一点。PS 一般来说,我设法从日志中找出出了什么问题(见附上的截图)。希望这可以为您节省一些时间。在此处输入图片说明

回答by aminhotob

In my case this error because I use Class name for variable

在我的情况下,这个错误是因为我使用类名作为变量

protocol Rotatable {
    func rotate() -> Self
}

extension Rotatable {
    func rotate(steps: Int) {
        for _ 0..<steps { self.rotate() }
    }
}

And this fixes my problem

这解决了我的问题

struct SomeStruct : Rotatable {

}

回答by mammut

I got Segmentation fault when I called a protocol function the same protocols extension.

当我将协议函数调用为相同的协议扩展时,出现了分段错误。

I had a code something in the line with this:

我有一个与此相符的代码:

var url: String!?

When I later made an object and declared that it would follow the Rotatable protocol I got Segmentation fault 11 and the program crashed.

后来我创建了一个对象并声明它将遵循 Rotatable 协议时,我遇到了 Segmentation fault 11 并且程序崩溃了。

Ex: this would cause Segmentation fault and crash Xcode

例如:这会导致分段错误并使 Xcode 崩溃

##代码##

If I however first implemented the function rotate() in SomeStruct and then afterwards declared that it conformed to Rotatable there where no problem.

但是,如果我首先在 SomeStruct 中实现了 rotate() 函数,然后在那里声明它符合 Rotatable 没有问题。

回答by George M

I had a similar today and tried the steps described here including removing files I had recently modified. Nothing seemed to work. I tried something that had been suggested when SourceKit would crash in Xcode.

我今天有一个类似的,并尝试了这里描述的步骤,包括删除我最近修改过的文件。似乎没有任何效果。当 SourceKit 在 Xcode 中崩溃时,我尝试了一些建议。

I when into the derived data directory and deleted everything. The location is listed under "Preferences -> Locations -> Derived Data" There is an arrow icon right next to the path which opens finder with that directory selected. Select all the directories inside and delete them. Close Xcode and Reopen it. That made the problem disappear for me.

我当进入派生数据目录并删除所有内容时。该位置列在“首选项 -> 位置 -> 派生数据”下 路径旁边有一个箭头图标,可打开 finder 并选择该目录。选择里面的所有目录并删除它们。关闭 Xcode 并重新打开它。这让我的问题消失了。

I think that some intermediate file is getting corrupted and the compiler does not know how to handle it.

我认为某些中间文件已损坏,编译器不知道如何处理。

回答by abanet

I get this error because a silly mistake!!

我收到这个错误是因为一个愚蠢的错误!!

in a class I defined

在我定义的类中

##代码##

:)

:)

So it seems that this description is a multiple & generic error for a lot of reasons!!

因此,由于很多原因,此描述似乎是一个多重和通用错误!!

回答by superarts.org

For me it's caused by adding the swift files to different targets (today extension in my case).

对我来说,这是由于将 swift 文件添加到不同的目标(在我的情况下是今天的扩展)引起的。