Command failed due to signal: Abort trap: 6

前端 未结 30 2222
暖寄归人
暖寄归人 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:41

    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 {
            ...
        }
    }
    
    0 讨论(0)
  • 2020-12-01 09:41

    My case, Swift 5.1, Xcode 10.3 (10G8)

    Code was crashing Swift when a nested function was using the argument of an outer function as a default parameter.

    e.g.

    func foo(duration: TimeInterval) {
        func bar(duration: TimeInterval = duration) {
        }
    }
    

    I hope this helps.

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

    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.

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

    I didn't try other solutions. I got this problem for this setup:

    func speacialAdd(_ num1: Int, to num2: Int){
        func specialMultiply(_ digit1: Int, with digit2: Int = num2){ // SOURCE OF PROBLEM
            print(digit2)
            print(digit1)
        }
    
        specialMultiply(5)
    }
    
    class ViewController: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            print(speacialAdd(5, to: 6))
        }
    }
    

    This line is the source of problem. Defaulting it to a argument seems to not work for a nested function

    func specialMultiply(_ digit1: Int, with digit2: Int = num2) // ERROR
    

    Solutions are:

    func specialMultiply(_ digit1: Int, with digit2: Int) // OK
    func specialMultiply(_ digit1: Int, with digit2: Int = 6) // OK
    

    FWIW I actually first wrote this in playground and got a different error:

    Playground execution failed:

    error: Couldn't lookup symbols:
    __T013__lldb_expr_111speacialAddySi_Si2totF4num2L_Sifau

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

    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.

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

    This issue is still present in Xcode 10.2.1. After cleaning the build folder, the error went away.

    0 讨论(0)
提交回复
热议问题