17

I upgraded my xcode to 11.4 yesterday, now I can not archive my SwiftUI code to submit appstore, because error: "error: Segmentation fault: 11", "xxx-master.dia:1:1: Could not read serialized diagnostics file: Cannot Load File: Failed to open diagnostics file".

Any advices?

foolbear
  • 726
  • 1
  • 7
  • 19

2 Answers2

2

I root caused my occurrence of this error to usage of 'Self' in a class func for a XIB UIView. The error happened for me in XCode 11.5 and only the release build of the project. So, looks like the issue is in -O compilation. (It looks like the academic project named Swift has rediscovered the useful concept of Self)

THE EXAMPLE BELOW CAUSES segfault 11, FIXED BY REPLACING THE THREE "Self" WITH CLASS NAME "StyleHSView":

class StyleHSView: UIStackView, UITextFieldDelegate {

  @IBOutlet weak var styleNameTF: UITextField!

  @IBOutlet weak var urlTF: UITextField!

  // THIS FUNC CAUSES segfault 11, fix by changing Self to class name StyleHSView.
  class func Instantiate() -> Self {
    let nib = UINib.init(nibName: "StyleHSView", bundle: nil)
    if let view = nib.instantiate(withOwner: nil, options: nil).first(where: { return $0 is Self }) as? Self
    {
        return view
    } else {
        fatalError("No StyleHSView")
    }
  }
}
dlalpine
  • 51
  • 2
1

Similar to the experience of this commenter in the issue @foolbear commented above, this was caused by a modifier one of my views.

In my case, I was using an Introspect modifier on a UIViewRepresentable.

In the stack dump of your error, identify the view where the issue is happening and try removing view modifiers until the error goes away.

gnarlybracket
  • 1,691
  • 4
  • 18
  • 37