When I created a search box on the homepage, I was able to enter text in the input field while previewing in Xcode. However, after clicking "Build" and running the app, I couldn't type anything into the input field in the demo interface. Additionally, I received the following error message:
- If you want to see the backtrace, please set CG_NUMERICS_SHOW_BACKTRACE environmental variable.
- 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.
How can I fix this issue? Here is my ContentView.swift code:
import SwiftUI struct ContentView: View { @State private var searchText: String = "" @State private var isSearching: Bool = false
var body: some View {
    NavigationStack {
        GeometryReader { geometry in
            VStack {
                Spacer()
                    .frame(height: geometry.size.height.isNaN ? 0 : geometry.size.height * 0.3)
                
                VStack(spacing: 20) {
                    Text("NMFC CODES LOOKUP")
                        .font(.title2)
                        .bold()
                    
                    TextField("Search...", text: $searchText)
                        .textFieldStyle(PlainTextFieldStyle())
                        .padding(10)
                        .frame(height: 40)
                        .frame(width: geometry.size.width.isNaN ? 0 : geometry.size.width * 0.9)
                        .background(Color.white)
                        .cornerRadius(8)
                        .overlay(
                            HStack {
                                Spacer()
                                if !searchText.isEmpty {
                                    Button(action: {
                                        searchText = ""
                                    }) {
                                        Image(systemName: "xmark.circle.fill")
                                            .foregroundColor(.gray)
                                            .padding(.trailing, 8)
                                    }
                                }
                            }
                        )
                        .overlay(
                            RoundedRectangle(cornerRadius: 8)
                                .stroke(Color.gray.opacity(0.5), lineWidth: 1)
                        )
                    Button(action: {
                        isSearching = true
                    }) {
                        Text("Search")
                            .foregroundColor(.white)
                            .frame(width: geometry.size.width * 0.9, height: 40)
                            .background(Color.blue)
                            .cornerRadius(8)
                    }
                    .disabled(searchText.isEmpty)
                    
                    Text("Created & Designed & Developed By Matt")
                        .font(.caption)
                        .foregroundColor(.gray)
                        .padding(.top, 10)
                }
                
                Spacer()
                    .frame(height: geometry.size.height * 0.7)
            }
            .frame(width: geometry.size.width)
        }
        .background(Color(red: 250/255, green: 245/255, blue: 240/255))
        .navigationDestination(isPresented: $isSearching) {
            SearchResultsView(searchQuery: searchText)
        }
    }
    .background(Color(red: 250/255, green: 245/255, blue: 240/255))
    .ignoresSafeArea()
}
}
#Preview { ContentView() }
 
  
  
  
    
  
