< Back

Introducing InstantSearch iOS: Create Great Search UX with Swift and Objective-C

We’re excited today to be releasing InstantSearch iOS, a library of views and helpers for building a great search experience on iOS. It is built on top of Algolia’s Swift API Client to give iOS developers a way to quickly build a search experience that will delight their users.

Before we dive into how InstantSearch iOS works, let’s talk about why we need this library in the first place.

Implementing search on iOS today: hard and complex

Mobile screen sizes are small by nature, which makes it hard for end users to see and filter their results. It is therefore expected that developers invest a lot of their time into building a search experience. Let’s explore possible ways to implement search on iOS today, as well as their costs and benefits.

Local search

The most basic search experience that you can provide is by creating a local search on the data that you have on your device. This data can reside in one of the following places:

It is fairly straightforward to implement a basic string matching algorithm. Just follow a tutorial such as the Raywenderlich one, and you’ll get something working in an hour or so. They even add a way to filter by one refinement by scoping with a scope bar.

Benefits:

  • No 3rd party dependencies, you’re in complete control
  • Easy to implement and maintain
  • Free

Costs:

  • Low quality. This is a basic search implementation; no advanced features such as typo tolerance, custom rankings and synonyms.

Implement search on your backend

Another popular way of implementing search on mobile is to provide a search functionality from a backend. If you do it this way, the mobile app would request search results by simply making a network request to your backend and adding the query and the filters in the request.

This is the most complex way to implement your search since you have to take care of every part of your search architecture: the search business logic on the backend, the communication between the backend + iOS, and finally the presentation and update of your search UI experience.

Benefits:

  • No 3rd party dependencies, you’re in complete control
  • Reuses the search business logic across more platforms such as Android and web

Costs:

  • Complex implementation for getting relevant, typo-tolerant search results with custom rankings
  • Need to host it and maintain it on your server

Search-as-a-service

The last way to implement a search experience is to rely on a 3rd party search-as-a-service to provide you search results and refinement capabilities. That way, the mobile app will just have to call an API over the network to get all the search results. This means speed superior to other solutions’, plus the search backend is taken care for you in this case.  

Benefits:

  • Premium search features that work out of the box: speed, relevance, typo-tolerance. No need for search expertise on your part.
  • Reuse the search business logic across more platforms such as Android and web.
  • Search backend taken care for you, no need to worry about hosting and availability.

Costs:

  • Reliance on 3rd party company
  • Costs some money to use SaaS

The common pitfall  

All of the three methods above will help you build the search business logic of your app, but they have something missing: you still need to build the search UI on the iOS app. If you’ve tried to build a complex UI search experience, you quickly found out that it can be tough to get it right: from dealing with all the states of the search lifecycle to updating all components as results come or filters change, it can be quite a challenge to implement a search UI correctly.

Introducing InstantSearch iOS

InstantSearch iOS offers a way to easily build search UI experiences on iOS by using Algolia as the backend search-as-a-service. It lets the developer focus on the look and feel of their app, without having to worry about Algolia API calls, or query crafting and state management.

Search is its own domain of expertise

Search is very complex if you want it to be done in a correct way. A good search has to provide speed, relevance and typo tolerance, which is a lot to ask, especially to mobile developers whose primarily skill is building apps, not writing algorithms for fetching the most relevant search results.

Translate the concepts of search into UI

Thinking in terms of terms such as disjunctive faceting offers a lot of cognitive complexity to the developer. InstantSearch makes it easy since developers will only have to think in terms of “and”, “or”, “<”, “==” instead of difficult concepts such as the difference between conjunctive and disjunctive faceting.

Heavy lifting of the implementation

Dealing with the search state can be quite cumbersome. For example, how would you handle the state when requests come out of order? Also, you have to handle all parts of the search lifecycle, be it the initial default state, the no result state, or the new result/error state. Finally, you have to deal with all the data binding and keep all UI components in sync with the actual search state. InstantSearch iOS has been built to take care of all of that for you.

Widgets offered with UX best practices

InstantSearch iOS provides you with numerous UI components called widgets, which are “search aware” components built on top of UIKit objects such as UITableView, UICollectionView and UISearchBar. These widgets follow search best practices on small mobile screens that will help the developer build great UX.

Pan-platform UX

The nice thing about InstantSearch iOS is that it has many siblings such as InstantSearch Android, InstantSearch.js, and more. What this means for you is that you get to use one search engine with myriad possibilities, while having a uniform and consistent UX across all platforms.

Plug-in architecture: an extensible library

As you use the library more and more, you might stumble upon a case where none of the provided widgets fit your needs. InstantSearch iOS has been built following Plug-in Architectures standards, which means that the library is modular, customizable and easily extensible.

The most important offering is the creation of custom widgets by implementing a few protocols on your UIView class. These protocols will provide you the relevant information that the widget needs, such as new search results coming by, or notifications of refinement changes happening in other widgets.

Getting started

The Getting Started Guide will take you through the main steps to use the library. The library is open source and can be found in this repo. The example application is a great addition to the guide as it’ll help you get an idea of what you can build with InstantSearch iOS.

If you use a Backend-as-a-Service to power your mobile apps, there are guides on how to sync your data between them and Algolia, such as the Firebase guide and the Graphcool guide.

To share your thoughts or ask for help, you can reach out on Algolia Community or Stack Overflow. Please share your projects, too! We look forward to seeing what you’ll build with InstantSearch iOS.