Command failed due to signal: Abort trap: 6

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

    For me below statement cause an error.

    let dict = mainDict as [String:String]
    

    Fix the issue by force unwraps

    let dict = mainDict as! [String:String]
    

    There is nothing related to the compiler. It is just type casting issue, Apple should give proper description instead of the giving compiler error

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

    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:

    • A compiler crash when calling C or Objective-C functions that take SIMD float3 parameters has been fixed. (21294916)

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

    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.

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

    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.

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

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

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