Group Group Group Group Group Group Group Group Group

Core Motion with error thread 1: EXC_BAD_INSTRUCTION

#1

Hi,I get an error when I first run the app “DreamWalker”(WatchOS by Tutorials, Chapter 22).
The app on iPhone can run while the app in apple watch always on loading. And Xcode reports an error in DreamWalker -> Shared -> Walk.swift. The code is here:

extension UIColor {
convenience init(colorArray array: NSArray) {
let r = array[0] as! CGFloat Thread 1: EXC_BAD_INSTRUCTION(code=EXC_I386_INVOP, subcode=0x0)
let g = array[1] as! CGFloat
let b = array[2] as! CGFloat
self.init(red: r/255.0, green: g/255.0, blue: b/255.0, alpha:1.0)
}
}

I have run the app both on simulator and iPhone, apple watch. Also, run the completed app in the folder final. But all get this issue. No idea how to fix this.

Thanks in advance.

#2

Hi @haowu, thanks for getting in touch. I’ve had a look at the project and I can reproduce the issue that you are facing :confused:

I’ve notified the team about this so that we can fix the issue properly however for the time being you can replace the UIColor extension in Walk.swift with the following and the project will work again:

extension UIColor {
  convenience init(colorArray array: [Int]) {
    let r = CGFloat(array[0])
    let g = CGFloat(array[1])
    let b = CGFloat(array[2])
    self.init(red: r/255.0, green: g/255.0, blue: b/255.0, alpha:1.0)
  }
}

Thanks for flagging this, please let us know if you have any further issues :bowing_man: :watch: