What's New

Hello Swift PM



This version is all about making SHSearchBar compatible with SPM and Swift 5.3.


I had to say goodbye to Cocoapods and Carthage. Since Apple recommends to not make assumptions about resource locations I have to use Bundle.module (read more about it here and here) which is not auto-generated by Carthage or Cocoapods at the moment. Apart from that I cannot detect the dependency manager at runtime and therefore would have to fallback to my own resource location algorithm. I don't know if this was intended by Apple 🤷...

Closed PRs


Twitter CI status Github Current Release Cocoapods Platforms Xcode 12.0+ iOS 10.0+ Swift 5.3+ Github Repo Size Github Code Size Github Closed PR's Carthage compatible License Codebeat Donate

The clean and shiny search bar that does what UISearchBar does only with dirty hacks. This view is designed to tackle the customization limits of UISearchBar. The difference here is that this class does not inherit UISearchBar but composes a new UIView object by using a UITextField that is much easier to use. These are the limits of the UISearchBar:

  • no clean way to left align the placeholder
  • the cancel button is hard to tailor to your needs
  • generally the appearance is not customizable (e.g. the font of the text)
  • there are some strange behaviors when you set a custom background image

Since I use a UITextField these restrictions do not apply.


Swift Package Manager

In Xcode open your target list and select your project. Click the tab Swift Packages and there the small + icon. Enter the URL of this repository, select the version you want to install - usually the preset is okay - and confirm.


Since SHSearchBar uses localized resources I dropped CocoaPods support in favor for SPM from version 2.0.0. Please integrate the package via SPM (see above).


Since SHSearchBar uses localized resources I dropped Carthage support in favor for SPM version 2.0.0. Please integrate the package via SPM (see above).


The repo includes an example project. It shows shows different use cases of the searchbar. To run it, just type pod try SHSearchBar in your console and it will be cloned and opened for you. The following images show some of these use cases:

You can show a custom placeholder like for normal text fields:

And you can even type text into that searchbar:

Wow there are customizable accessory views too:
Accesssory Icon

Easily customize text and cancel button as you want:
Customizable text and ancel button

You can customize each corner radius of the text field so that layouts like this become an ease:
Corner Radius Customization

The inner text field supports the new iOS 10 'textContentMode':
(Re-uses the address searched in Apple Maps before)
UITextContentMode Support

You can use the search bar inside a UINavigationBar:
UINavigationBar Support


  • If you found a bug, please open an issue.
  • If you have a feature request, please open an issue.
  • If you want to contribute, please submit a pull request.


Stefan Herold🐦 @Blackjacxxx


SHSearchBar is available under the MIT license. See the LICENSE file for more info.


  • Swift Tools 5.3.0
View More Packages from this Author


Last updated: Sat Nov 26 2022 20:43:36 GMT-0500 (GMT-05:00)