.searchable SwiftUI on IOS 17 cause an error: invalid numeric value
Asked Answered
F

1

14

Simulator: iPhone 15 with IOS 17 Xcode: Version 15.0 (15A240d)

Simple example on just created project:

import SwiftUI

struct ContentView: View {
    @State private var searchText = ""

      var body: some View {
          NavigationStack {
              Text("Searching for \(searchText)")
                  .navigationTitle("Searchable Example")
          }
          .searchable(text: $searchText)
      }
}

#Preview {
    ContentView()
}

When start tapping any text throw:

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.

After clicking and canceling start show error below on every click:

-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform input operation requires a valid sessionID

Does someone know how to fix?

I found a thread on apple forum https://developer.apple.com/forums/thread/731700, but as always no single answer from devs.

Fusible answered 23/9, 2023 at 21:34 Comment(1)
I was able to solve this error while developing an iOS app (17). my issue: I did not set up the entry point {@main of my app}. my situation was that I had a widget extension and never imported WidgetKit nor added update widget at main. my app functioned as the error persisted....I was not updating widget at entry, so app never crashed, just the annoying NaN message. Once I imported WidgetKit, the error message stopped. basic error, once I set up the project and add whatever necessary routing or model context at main, I seldom look back at that file.Serena
O
0

That developer thread you linked had a suggestion to disable autocorrection. Seems to work in the meanwhile. Hopefully a fix comes through soon.

.autocorrectionDisabled()

Overmeasure answered 30/1 at 11:50 Comment(1)
No, that suggestion didn't work for me, unfortunately.Fusible

© 2022 - 2024 — McMap. All rights reserved.