Post

Replies

Boosts

Views

Activity

Reply to Xcode not showing compile errors when app crashes
Thanks both for your suggestions. Apologies as I am new to Xcode. I meant Xcode could not show error of runtime crashes. Here is where I suspect the runtime crash happening in ContentView: ... var body: some View { NavigationView { List { ForEach(selectedContactIdentifiers.indices, id: \.self) { index in Button(action: { contactToEditIndex = index showingActionSheet = true }) { HStack { Image(systemName: "person.crop.circle.fill") .foregroundColor(.gray) .font(.largeTitle) if let contact = fetchContact(with: selectedContactIdentifiers[index]){ //where runtime crash most probably happened Text("\(contact.givenName) \(contact.familyName)") } else { Text("Unknown Contact") } ... } func fetchContact(with identifier: String) -> CNContact? { let store = CNContactStore() let keysToFetch = [CNContactGivenNameKey, CNContactFamilyNameKey] as [CNKeyDescriptor] do { let contact = try store.unifiedContact(withIdentifier: identifier, keysToFetch: keysToFetch) return contact } catch { print("Error fetching contact:", error) return nil } } ... I would have thought Xcode would automatically catch the exception and show the point of crash in the code.
Oct ’23