Command failed due to signal: Abort trap: 6

匿名 (未验证) 提交于 2019-12-03 02:14:01

问题:

Since Xcode 7 and Swift 2.0, I get the error above, like in the screenshot shown here:

I have no idea where this is coming from, clean and deleting derived data didn't work.

Anyone else experiencing this problem?

project:

target:

回答1:

I have the same problem with all Xcode 6.3 projects, I open in Xcode 7.0. I created a new project, copied all my source files and resources and everything worked without this compiler error. I thought this has something to do with the project settings. I turned off the Swift compile Optimization to "none" and the Trap 6 was gone away. Perhaps there are other settings, which also generate trouble, but for me this it was.



回答2:

In my case

Error

override func observeValueForKeyPath(keyPath: (String!)?, ofObject object: (AnyObject!)?, change: ([NSObject : AnyObject]!)?, context: UnsafeMutablePointer<Void>) 

Ok

override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [NSObject : AnyObject]?, context: UnsafeMutablePointer<Void>) 


回答3:

Go to project Build settings -> Swift Compiler - code generation -> Optimization Level -> For both Debug & Release select option "Fast,Single-File Optimaiztion[-O]



回答4:

I got this error too on XCode 7 Beta 5. After I clean the build, then I got another error saying one of my class not conforming to the protocol I just changed. After I fix the issue, it builds. The protocol changes I made is to change two parameter type of a method from Int to Int32



回答5:

In my case,

The compiler would give me the message:

Incorrect number of arguments passed to called function! %4 = call %swift.type* @_T015SimplifiedCoder6StructVMa() #1, !dbg !3112 <unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log <unknown>:0: note: Broken function found, compilation aborted! 

but I realized that I missed a default generic parameter:

class Class<K> {     init<T: Protocol>(_ value: T) where T.Key == K {} }  protocol Protocol {     associatedtype Key     static func getClass<NewKey>(_: NewKey.Type) -> Class<NewKey> }  struct Struct<K>: Protocol {      typealias Key = K      static func getClass<NewKey>(_: NewKey.Type) -> Class<NewKey> {         let _self = Struct<NewKey>()         return Class(_self)     } }  protocol CanGetClass {     associatedtype StructType: Protocol }  extension CanGetClass {     func getClass<Key>(_: Key.Type) -> Class<Key> {         return StructType.getClass(Key.self)     } }  struct R: CanGetClass {     typealias StructType = Struct } 

changed:

typealias StructType = Struct 

to:

typealias StructType = Struct<Int> 

the extension of CanGetClass tried to call getClass on an incomplete type.



回答6:

I received this when did that:

protocol ProtocolA {     associatedtype BType: ProtocolB }  protocol ProtocolB {     associatedtype AType: ProtocolA } 


回答7:

In my case, it was with setting a value to a parameter in a function to nil that was causing the error.

Before:

public func comparableValidator<T: Comparable>(minValue : T? = nil, maxValue : T? = nil, value: T) -> Void {     if let min = minValue {         _assertFunc(min <= value, "\(value) must be at least \(min)")     }      if let max = maxValue {         _assertFunc(max >= value, "\(value) must be at most \(max)")     } } 

After:

public func comparableValidator<T: Comparable>(minValue : T?, maxValue : T?, value: T) -> Void {     if let min = minValue {         _assertFunc(min <= value, "\(value) must be at least \(min)")     }      if let max = maxValue {         _assertFunc(max >= value, "\(value) must be at most \(max)")     } } 


回答8:

I am able to reproduce this simply and consistently with a brand-new project created in Xcode 7.0 beta (7A120f). Note that the problem is likely more broad than the example, but this is 100% reproducible for me by only adding a single line to a new project. This problem also appears to exclusively apply to iOS, not OS X, at least for this example. Have submitted bug report # 21376523 to Apple.

  1. Create a brand-new project in Xcode 7.0 (7A120f). Type is "Game", Language is "Swift", Game Technology is "SceneKit".

  2. Build and run with default settings. Project builds and runs fine in simulator (you will see the default rotating 3D spaceship model).

  3. Add a single SCNVector3 property to GameViewController.swift, like this:

    class GameViewController: UIViewController {     var p = SCNVector3Zero   

--> Produces "Abort trap: 6". Project will no longer compile.

  1. Change the constant to an empty initializer.

    class GameViewController: UIViewController {     var p = SCNVector3()   

--> Same problem, "Abort trap: 6"

  1. Remove property, restoring to the clean project state.

--> "Abort trap: 6" is gone, project again compiles and runs.

  1. Change "var" to "let".

    class GameViewController: UIViewController {     let p = SCNVector3Zero 

-- > Compiles and runs.

  1. Change property type to SCNVector4 instead of SCNVector3.

    class GameViewController: UIViewController {     var p = SCNVector4Zero 

-- > Compiles and runs.

EDIT: This problem is fixed in Xcode 7.0 beta-2 (7A121l), if you are getting "Abort trap: 6" due to using a float 3 vector type (such as SCNVector3). From the release notes:



回答9:

Ok, in my case it was because I had an enum nested in a generic class. Now, the strange thing, is that when I isolated the problem (into the BaseDao2), the compiler told me the right error, but in my real BaseDao implementation (which has more stuff), it throw "trap 6".

Type 'DaoError2' nested in generic type 'BaseDao2' is not allowed 

When I had this:

class BaseDao2<T>: InjectRestSession{      enum DaoError2: ErrorType{         case FAILED_RESPONSE(String)         case INVALID_RESULT(String)         case FAIL_TO_LIST, FAIL_TO_GET     }      func get() -> T?{         return nil     } } 

Anyway, in my case, I move the DaoError out of the BaseDao and everything compiled. Anyway, my feeling is that "trap 6" is what something cannot compile and the compiler got confused. Starting from a simple case, and adding back what you think might be causing the problem can be helpul to identify the problem by getting the right compile error. In other word, you have to be gentle with the swift compiler.



回答10:

This is what caused the error for me.

Before:

    for (key,value) in hash{         count += value.count     } 

After:

    for (_,value) in hash{         count += value.count     } 

It didn't like it that key was never being used anywhere. I am not sure why it should cause the build to fail though.



回答11:

I managed to get my project to build by setting the optimisation level to 'None' under the 'Swift Compiler - Code Generation' menu in the target (not the project) settings. See the screenshot below...

This shouldn't be a permanent solution because it more than doubles the size of the ipa. It should be possible to switch optimisation back on when Xcode 7 comes out of beta.



回答12:

In my case i had @objc protocol with optional methods and when i called its methods also in swift class i got that error, after removing the optional keyword from functions in the protocol the error was gone.

before (with error):

@objc protocol SomeDelegate:NSObjectProtocol{      optional func someDelegateMethod() }  class MySwiftClass{     func notifyMyDelegate(){         mydelegate?.someDelegateMethod?() //this line caused the error     } } 

after:

@objc protocol SomeDelegate:NSObjectProtocol{      func someDelegateMethod() }  class MySwiftClass{     func notifyMyDelegate(){         mydelegate?.someDelegateMethod()     } } 


回答13:

for me.. I modified the content of a @objc function like so:

before:

        @objc func didConnectWithSession() {            context!.stream.disconnectAfterSending()         } 

after:

        @objc func didConnectWithSession() {            //context!.stream.disconnectAfterSending()         } 

This caused the error. I resolved by removing the entire function.



回答14:

I got this message when using do-try-catch in a Failable initializer:

public init?() {     do {         ...         super.init(superParam: try getParamForSuper())         ...     } catch {         ...     } } 

The compilation succeeded when moving the try call to it's own local variable:

public init?() {     do {         ...         let superParam = try getParamForSuper()         super.init(superParam: superParam)         ...     } catch {         ...     } } 


回答15:

In my case I had a private struct Constants declared in both class A and extension A.

Probably it should be giving an error but it didn't.



回答16:

To me what caused this error was:

I created a file to create extensions on UIView. Inside this file, I created a private protocol named Foo.

Then I made:

extension UIView: Foo

Removing the private from the protocol made the error go away.

I guess this is probably a bug. The compiler should warn us about the issue. The same way it warns us we can't add private conformances to types it should tell us that conformance should be using a "public/internal" protocol.



回答17:

I resolved this problem with these steps:

  1. ran 'pod deintegrate'

  2. Makesure podfile like this: platform :ios, '8.0' use_frameworks!

  3. ran 'pod install'



回答18:

In my case, renames several parameters of init methods which is a protocol fails the compilation. I solve it by do it one by one, compiles again after each change.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!