DCDC DCDC - 1 year ago 112
iOS Question

Xcode: Persisteng Segmentation fault:11 when using Firebase

I'm getting mad with


Command failed due to signal: Segmentation fault:11


When I use Firebase in my project.

I read multiple question here about this Xcode bug, but it's terribly persisent when using Firebase.

I tried many solutions like cleaning the project, rebuilding, disabling bitcode etc.

My code:

@IBAction func saveBook(sender: UIBarButtonItem) {


var arrayOfNames : [String] = [String]()
for i in 0 ..< 6 {
let indexPath = NSIndexPath(forRow:i, inSection:0)
let cell : LongNameTableViewCell? = self.tableView.cellForRowAtIndexPath(indexPath) as! LongNameTableViewCell?
if let item = cell?.textField.text {
arrayOfNames.append(item)
}
}
print("ss")
self.ref.child("books").childByAutoId().setValue(["title": arrayOfNames[0], "author": arrayOfNames[1], "pages_count":arrayOfNames[2]])
self.dismissViewControllerAnimated(true, completion: nil)

}

Answer Source

As usually mentioned in similiar questions, this issue occurs when Xcode is for some reason unable to parse the code eq. variable types are ambiguous.

Although this is rather a workaround that a recommended fix, it worked for me:

self.ref.child("books").childByAutoId().setValue(["title":arrayOfNames[0] as! String, "author": arrayOfNames[1] as! String, "pages_count":arrayOfNames[2] as String!])

Obviously now Xcode shows warning that this kind of casting makes no sense, but fortunately this clears the error message.