Xcode 8 (Swift 3) Command failed due to signal: Killed: 9

前端 未结 5 1630
一向
一向 2021-01-02 00:52

After upgrading to Xcode 8 and converting all my code to Swift 3, I have troubles compiling swift resources. It takes a very long time, and my computer gets super laggy and

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 01:22

    In my case, I was writing a class that implemented Equatable and also had generic members. My issue was rooted in comparing the generic members with ==, when the generic class didn't have a == operator implemented.

    For example (using Variable from RxSwift):

    class Foo: Equatable {
    
      var fieldOne: Variable = Variable("fieldOne")
      var fieldTwo: Variable = Variable(nil)
    
      public static func ==(lhs: Foo, rhs: Foo) -> Bool {
        //should be marked as a compiler error, since Variable doesn't have == 
        return lhs.fieldOne == rhs.fieldOne && lhs.fieldTwo == rhs.fieldTwo 
      }
    
    }
    

    I should have seen a compiler error for this since no definition of == exists for Variable, but the compiler would crash (as well as the static analysis) before being able to show it. I was seeing memory usage of 60GB+ before the crash. Yikes.

    It seems swift still has some lingering bugs when it comes to generics.

提交回复
热议问题