Command failed due to signal: Abort trap: 6

前端 未结 30 2221
暖寄归人
暖寄归人 2020-12-01 08:56

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

\"screenshot

相关标签:
30条回答
  • 2020-12-01 09:48

    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.

    0 讨论(0)
  • 2020-12-01 09:49

    Make sure you don't implement a private protocol into class extension. Most of the time would be quite strange to have a private protocol, but not necessary, depending on what you wish to encapsulate.

    Something like, in the same file:

    class C: ... {
    }
    
    extension C: P {
    }
    
    private protocol P: class {
    }
    

    Do this an you'll surely get Command failed due to signal: Abort trap: 6

    Instead remove the private modifier from the protocol and the error is fixed.

    0 讨论(0)
  • 2020-12-01 09:50

    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.

    0 讨论(0)
  • 2020-12-01 09:51

    I got this error when attempting to run tests. To solve it, I put this script into Terminal:

    rm -rf ~/Library/Developer/Xcode/DerivedData

    Deleting derived data resolved the issue

    0 讨论(0)
  • 2020-12-01 09:51

    For me it was MD5.swift issue

    What you have to do is search in your project for file name "MD5.swift" even in the pods

    and replace all the content with this file here

    https://github.com/onmyway133/SwiftHash/blob/master/Sources/MD5.swift

    0 讨论(0)
  • 2020-12-01 09:52

    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)")
        }
    }
    
    0 讨论(0)
提交回复
热议问题