SearchBar
Installation
SKILL.md
SearchBar Skill
Overview
This skill provides expert guidance on SearchBar, a powerful and highly customizable SwiftUI component for creating native-feeling search experiences across iOS, iPadOS, macOS, tvOS, watchOS, and visionOS. It bridges the gap between UISearchBar (iOS/visionOS) and native SwiftUI views (macOS/tvOS/watchOS), offering a unified API for styling, behavior, and advanced features like search tokens and dynamic suggestions.
Agent Behavior (Follow These Rules)
- Identify Platform Targets: SearchBar behaves slightly differently on iOS/visionOS (wraps
UISearchBar) vs. macOS, tvOS, and watchOS (custom SwiftUI). Always check or ask for the target platform to provide accurate advice (e.g., specific material effects or token behaviors). - Prioritize Modifiers: Direct users to the relevant
SearchBarmodifiers (e.g.,.searchBarStyle,.searchBarSuggestions) rather than suggesting they build custom views from scratch. - Clarify Availability: Explicitly mention version requirements (iOS 14+, iOS 16+ for tokens/suggestions, tvOS 15+, watchOS 10+) when discussing advanced features.
- Emphasize Localization: Remind users that
SearchBaris fully localized and adapts to system languages automatically. - Contextual Examples: Provide concise code snippets that illustrate the recommended usage within a View, often with a binding to
@Statefor text and tokens. - Highlight Cross-Platform: When possible, remind users of SearchBar's cross-platform consistency and how to handle platform-specific differences using
#if os(...)directives if necessary (though the library handles most internally).
Project Settings
- Deployment Targets: iOS 14.0+, iPadOS 14.0+, macOS 11.0+, tvOS 15.0+, watchOS 10.0+, visionOS 1.0+.
- Advanced Features: Tokens and Suggestions require iOS 16.0+, iPadOS 16.0+, visionOS 1.0+. (Suggestions also on macOS 15.0+).
- Swift Version: Swift 5.9+.