Xcode 10.1 freezes while compiling

1. Analysis Based on G Purcell's answer, I concentrated my focus on my SCNViews. This made it stop crashing (removing subtype names for all SCNViews):

enter image description here

But I could not make the custom classes initialize properly. I wouldn't work for me casting them at runtime to their subtypes, and XCode was still crashing sometimes.

2. The fix There was no other way than writing code, and I am including it here, only if anyone else needed some help initializing the SCNViews programmatically (I struggled, first tried keeping the generic SCNViews.) So I removed all SCNViews alltogether (OK, not all - it still compiles with the two-three SCNViews in StoryBoard,) and added a UIView as a placeholder with the same constraints as before.

SCNView subclass:

First make sure the init(frame:) method is implemented -- in the case there is something going on in the init, add a custom init func, so it is called from either init:

override init(frame: CGRect) {
    super.init(frame: frame, options: nil)
    self.layoutIfNeeded()
    self.customInit()
}
required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)!
    customInit()
}
func customInit(){
    self.sceneSetup()
    self.intro()
    self.layoutIfNeeded()
}

ViewController:

override func viewDidLoad() {
    super.viewDidLoad()
    self.customSceneView = CustomSceneView(frame: customSceneContainer.bounds)
    self.customSceneContainer.addSubview(self.customSceneView)
    self.customSceneView.widthAnchor.constraint(equalTo: customSceneContainer.widthAnchor, multiplier: 1).isActive = true
    self.customSceneView.heightAnchor.constraint(equalTo: customSceneContainer.heightAnchor, multiplier: 1).isActive = true
}

Result: Finally everything compiled, my Mac stayed awake. Some new additional constraints needed to be added for correct resizing when rotating the device. But at last, and after two months, I could upload new features to the App Store. :)


I'm quite surprised that an app can freeze the entire Mac, even an app that comes from Apple.

After a lot of frustration with this issue I found the following workaround that works for me:

  1. Build the app until the Mac freezes.
  2. Wait a little bit longer (10-20 seconds).
  3. Hold down the Mac's power button until it turns off.
  4. Turn on your Mac.
  5. Open the main storyboard and slightly move one of the view controllers.
  6. Save the storyboard and open any other file.
  7. Build the app again - This time the Mac does not freeze

Any rebuild works fine for me as long as the storyboard was not touched.


I was having the exact problem, so I watched my build tasks click by. It turns out I was suffering a full system freeze during the

Compile Storyboard file...

step of my Main storyboard file. (My Storyboard wasn't terribly large. ~10 View Controllers)

I recreated my project and, for me, the instability came about when I began adding a couple SCNViews. When I removed them all, and programmatically created those views, my Storyboard compile step passed and my app launched.

I'm not sure it's specifically SceneKit causing issues, but something was causing my Storyboard to fail compilation. It's worth a start to try there: backup the project, delete everything in the Storyboard, and see if you're still crashing. (This definitely wasn't happening under 10.0)

Tags:

Macos

Xcode