API Reference / API Methods / Install the Swift API Client

Install the Swift API Client

Swift Package Manager

The Swift Package Manager is a tool for managing 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 SwiftPM, you should use Xcode 11 to open your project. Click File -> Swift Packages -> Add Package Dependency, enter InstantSearch repo’s URL.

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

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

Add import AlgoliaSearchClient to your source files.

Cocoapods

CocoaPods is a dependency manager for Cocoa projects.

To install Algolia Swift Client, simply add the following line to your Podfile:

1
2
3
pod 'AlgoliaSearchClient', '~> 8.0'
# pod 'InstantSearchClient', '~> 6.0'` // Swift 4.2
# pod 'InstantSearchClient', '~> 5.0'` // Swift 4.1

Then, run the following command:

$
$ pod update

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa.

  • To install InstantSearch, simply add the following line to your Cartfile:
    1
    2
    3
    
    github "algolia/algoliasearch-client-swift" ~> 8.0.0
    # github "algolia/algoliasearch-client-swift" ~> 6.0.0` // Swift 4.2
    # github "algolia/algoliasearch-client-swift" ~> 5.0.0` // Swift 4.1
    
  • Launch the following commands from the project directory (only for version 8.0+)
    1
    2
    3
    
     carthage update
     ./Carthage/Checkouts/algoliasearch-client-swift/carthage-prebuild
     carthage build
    

Supported platforms

The API client is compatible with Swift 5.0+ and supported on iOS, macOS, tvOS and watchOS.

Language-specific notes

You can browse the automatically generated reference documentation.

Upgrading

If you were using version 2.x of our Swift client, read the migration guide to version 3.x.

Did you find this page helpful?