Guides / Building Search UI

Installing InstantSearch iOS

To confirm the latest version of InstantSearch iOS, please refer to our list of releases.

You can add InstantSearch iOS to your project using either Swift Package Manager, Cocoapods, or Carthage.

Swift Package Manager

The Swift Package Manager (SPM) is a tool to manage the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. Since the release of Swift 5 and Xcode 11, SPM is compatible with the iOS, macOS and tvOS build systems for creating apps.

To use SPM, you should use Xcode 11 to open your project. Click File -> Swift Packages -> Add Package Dependency, and enter the URL of the InstantSearch repository (https://github.com/algolia/instantsearch-ios). If you consider to use only the business logic modules of InstantSearch, and don’t need the set of provided UIKit controllers in your project, you only have to select InstantSearchCore in the list of products that show up.

If you’re a framework author and use InstantSearch as a dependency, update your Package.swift file:

1
2
3
4
5
6
7
let package = Package(
    // 7.1.0 ..< 8.0.0
    dependencies: [
        .package(url: "https://github.com/algolia/instantsearch-ios", from: "7.1.0")
    ],
    // ...
)

Cocoapods

CocoaPods is a dependency manager for Cocoa projects.

  • If you don’t have CocoaPods installed on your machine, open your terminal and run sudo gem install cocoapods.
  • If you don’t have a Podfile in your project, type pod init. A Podfile will be created for you.
  • Open your Podfile and add

To install InstantSearch, simply add the following line to your Podfile:

1
2
pod 'InstantSearch', '~> 7.1'
# pod 'InstantSearch/Core' for access to everything except the UI controllers
  • On your terminal, run pod update.

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa.

To install InstantSearch, simply add the following line to your Cartfile:

1
github "algolia/instantsearch-ios" ~> 7.1

Launch the following commands from the project directory:

1
2
3
carthage update
./Carthage/Checkouts/instant-search-ios/carthage-prebuild
carthage build

Note: At this time, Carthage does not provide a way to build only specific subcomponents (or equivalent of CocoaPods’s subspecs) of a repository. It will build all components and their dependencies with the above commands. However, you don’t need to copy frameworks you aren’t using into your project. For instance, if you don’t use the UI components from InstantSearch, you can delete all InstantSearch frameworks except InstantSearchCore from the the Carthage Build directory.

Did you find this page helpful?