Reputation: 326
I'm using the beta version of macOS Montery along with Xcode 13 beta 2, and I've been having a problem with the searchable
modifier.
Heres what I did:
struct ContentView: View {
@State var text: String = ""
var body: some View {
NavigationView {
}
.searchable(text: $text)
}
}
The app instantly crashes with this error once you run it:
dyld[7740]: Symbol not found: _$s7SwiftUI4ViewPAAE10searchable4text9placement6promptQrAA7BindingVySSG_AA20SearchFieldPlacementVAA4TextVSgtF
Referenced from: /Users/user/Library/Developer/Xcode/DerivedData/TestProj-cfncvdprydmxfxdxqyronusubbek/Build/Products/Debug/TestProj.app/Contents/MacOS/TestProj
Expected in: /System/Library/Frameworks/SwiftUI.framework/Versions/A/SwiftUI
I tried cleaning the build folder, and clearing the derived data of both Xcode 12, and the version of Xcode I'm using to build the project, which is Xcode 13 beta 2.
I've heard on this question that the issue is caused by different versions of Xcode beta and the target device. That makes sense here as I'm running Xcode beta 2, but with the first version of macOS Montery (I think). However, there is no second of macOS Montery available.
Nothing helped. What's going on?
Upvotes: 1
Views: 586
Reputation: 36782
As I understand it, searchable applies to List. I've had some issues as well, but the following code works for me on macOS 12 Monterey.
struct ContentView: View {
@State private var searchText: String = ""
@State private var options: [String] = ["one","two","three"]
var body: some View {
NavigationView {
List($options, id: \.self) { $option in
Text(option)
}
.searchable("Search options", text: $searchText, placement: .automatic){
Text("tw").searchCompletion("two")
}
}
}
}
Upvotes: 0