The Solutions:
Solution 1: Disable autocorrection
As per the discussion on the Apple developer forum, it is suggested to disable autocorrection to resolve the error “this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem.” This fix seems to work in the meantime, until an official fix is provided.
To disable autocorrection in your SwiftUI code, you can use the .autocorrectionDisabled() modifier. Here’s an example:
struct ContentView: View {
@State private var searchText = ""
var body: some View {
NavigationStack {
Text("Searching for \(searchText)")
.navigationTitle("Searchable Example")
}
.searchable(text: $searchText)
.autocorrectionDisabled() // Disable autocorrection
}
}
#Preview {
ContentView()
}
By adding the .autocorrectionDisabled() modifier, autocorrection will be disabled when the user enters text in the search field. This may help to resolve the error you are encountering.
Q&A
How to fix error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API?
Try to disable autocorrection using .autocorrectionDisabled()
Does the error occur only on simulators with iOS 17?
Yes, the error occurs only on simulators with iOS 17.
Is there an official fix from Apple yet?
No, there is no official fix from Apple yet.