New in SwiftUI 3: Finding content in SwiftUI 3, .searchable way

DevTechie
DevTechie
Published in
9 min readSep 20, 2021

--

Another awesome modifier that was introduced for iOS 15+ in SwiftUI 3 is .searchable. Like the name suggest, this modifier is used to add search functionality to your views and you are gonna love effortless way of adding searchbar to your apps.

Note: this modifier is only available for iOS 15 or above so you will need Xcode 13+. You will also need to make sure that your app target version is iOS 15 or above or put feature behind  #available(iOS 15.0, *).

If you prefer this article in video format check it out here 👇:

Definition for searchable looks like this:

func searchable(text: Binding<String>, placement: SearchFieldPlacement = .automatic) -> some View

text to display and edit in the search field.

placement is preferred placement of the search field within the containing view hierarchy.

Placement supports four predefined values:

--

--