I had this exact problem and after pain staking countless hours, I went through my entire app, removed everything and added each line back into the app and then built the app after every line...
I even continued to make sure it wasn't a fluke, but this line of code is what caused my Illegal instruction: 4
let pos = CGPoint(x: Double.random(in: 0 ... 2000), y: Double.random(in: 0 ... (self.view?.bounds.height)!))
This line was in a class called gameBoard: SKScene
Not sure if this will help anyone else's issue with illegal instruction: 4 but this is what caused mine and rewriting it fixed it.
Topic:
Programming Languages
SubTopic:
Swift
Tags: