algoliasearch-client-swift package is version 9.
This page helps you upgrade from version 8
and explains the breaking changes you need to address.
Algolia generates the version 9 clients from OpenAPI specifications,
which provides consistent behavior across all languages and up-to-date API coverage.
The main architectural changes are:
- The
index(withName:)pattern is removed. All methods are now on theclientinstance directly, withindexNameas a parameter. - Client initialization can throw, so
tryis required. - All API calls use Swift’s native
async/awaitconcurrency model. - All module names are prefixed with
Algolia(for example,import AlgoliaSearchinstead ofimport Search). - The client is compatible with Swift 6.
Update your dependencies
Swift Package Manager
Update your Swift Package Manager dependency to version 9. In yourPackage.swift, change the version requirement:
Swift
CocoaPods
If you use CocoaPods, update yourPodfile:
Ruby
With CocoaPods, all Algolia modules are bundled into a single
AlgoliaSearchClient module.
This means you use import AlgoliaSearchClient instead of the individual module imports
shown in the rest of this guide.To support CocoaPods’ module flattening,
some model names are prefixed with the client name to avoid conflicts.
This applies regardless of your installation method.
The prefixed names are more verbose,
but the tradeoff is better autocompletion in IDEs and more predictable structure
that works well with AI coding assistants.Update imports
Since version 9.40.0, all module names are prefixed withAlgolia to avoid conflicts with other dependencies.
The main module changed from AlgoliaSearchClient to AlgoliaSearch:
Swift
AlgoliaCore alongside the API-specific module,
since AlgoliaCore defines shared types such as SearchClient configuration and request options.
Version 9 includes dedicated modules for each API.
To access methods from a specific API,
import the corresponding module:
Swift
Update client initialization
In version 9,SearchClient initialization can throw,
requiring the try keyword:
Swift
The
try keyword is required because version 9 validates
your application ID and API key during initialization.
If you’re initializing the client inside a function that doesn’t already throw,
wrap it in a do/catch block.index(withName:) no longer exists.
Remove index(withName:)
This is the most significant change when upgrading.
Version 8 relied on an index object with methods called on it.
In version 9, all methods belong to the client instance,
with indexName as a parameter.
Swift
Add async/await
Version 9 is built on Swift’s native concurrency model. All API calls areasync functions that require try await.
In version 8, API calls rely on completion handlers:
Swift
Task:
Swift
Update search calls
Search a single index
Theindex.search() method is now client.searchSingleIndex().
Pass the index name and search parameters as named arguments:
Swift
Search multiple indices
Theclient.multipleQueries() method is now client.search().
Each request in the array requires an indexName:
Swift
Search for facet values
Theindex.searchForFacetValues() method becomes client.searchForFacetValues()
with an indexName parameter:
Swift
Update indexing operations
In version 9, indexing methods are on the client instead of the index object, withindexName as a parameter.
Add or replace records
Swift
Partially update records
Swift
Delete records
Swift
Update settings, synonyms, and rules
Get and set settings
Swift
Save synonyms and rules
Swift
In version 8,
index.replaceAllRules() and index.replaceAllSynonyms() replaced all rules or synonyms.
In version 9, use client.saveRules() or client.saveSynonyms() with the clearExistingRules or replaceExistingSynonyms parameter set to true.Update index management
ThecopyIndex, moveIndex, copyRules, copySynonyms, and copySettings
methods are all replaced by a single operationIndex method.
Copy an index
Swift
Move (rename) an index
Swift
Copy only rules or settings
In version 9, use thescope parameter to limit the operation to specific data:
Swift
Update task handling
Version 8 supported chaining.wait() on operations.
Version 9 replaces this pattern with dedicated wait helpers.
Swift
waitForTask: wait until indexing operations are done.waitForAppTask: wait for application-level tasks.waitForApiKey: wait for API key operations.
Method changes reference
The following tables list all method names that changed between version 8 and version 9.Search API client
| Version 8 (legacy) | Version 9 (current) | |
|---|---|---|
client.addAPIKey | → | client.addApiKey |
client.addAPIKey.wait | → | client.waitForApiKey |
client.clearDictionaryEntries | → | client.batchDictionaryEntries |
client.copyIndex | → | client.operationIndex |
client.copyRules | → | client.operationIndex |
client.copySynonyms | → | client.operationIndex |
client.deleteAPIKey | → | client.deleteApiKey |
client.deleteDictionaryEntries | → | client.batchDictionaryEntries |
client.generateSecuredAPIKey | → | client.generateSecuredApiKey |
client.getAPIKey | → | client.getApiKey |
client.getSecuredAPIKeyRemainingValidity | → | client.getSecuredApiKeyRemainingValidity |
client.listAPIKeys | → | client.listApiKeys |
client.listIndices | → | client.listIndices |
client.moveIndex | → | client.operationIndex |
client.batch | → | client.multipleBatch |
client.multipleQueries | → | client.search |
client.replaceDictionaryEntries | → | client.batchDictionaryEntries |
client.restoreAPIKey | → | client.restoreApiKey |
client.saveDictionaryEntries | → | client.batchDictionaryEntries |
client.updateAPIKey | → | client.updateApiKey |
index.batch | → | client.batch |
index.browse | → | client.browseObjects |
index.browseRules | → | client.browseRules |
index.browseSynonyms | → | client.browseSynonyms |
index.clearObjects | → | client.clearObjects |
index.clearRules | → | client.clearRules |
index.clearSynonyms | → | client.clearSynonyms |
index.copySettings | → | client.operationIndex |
index.delete | → | client.deleteIndex |
index.deleteBy | → | client.deleteBy |
index.deleteObject | → | client.deleteObject |
index.deleteObjects | → | client.deleteObjects |
index.deleteRule | → | client.deleteRule |
index.deleteSynonym | → | client.deleteSynonym |
index.findObject | → | client.searchSingleIndex |
index.getObject | → | client.getObject |
index.getObjects | → | client.getObjects |
index.getRule | → | client.getRule |
index.getSettings | → | client.getSettings |
index.getSynonym | → | client.getSynonym |
index.getTask | → | client.getTask |
index.partialUpdateObject | → | client.partialUpdateObject |
index.partialUpdateObjects | → | client.partialUpdateObjects |
index.replaceAllObjects | → | client.replaceAllObjects |
index.replaceAllRules | → | client.saveRules |
index.replaceAllSynonyms | → | client.saveSynonyms |
index.saveObject | → | client.saveObject |
index.saveObjects | → | client.saveObjects |
index.saveRule | → | client.saveRule |
index.saveRules | → | client.saveRules |
index.saveSynonym | → | client.saveSynonym |
index.saveSynonyms | → | client.saveSynonyms |
index.search | → | client.searchSingleIndex |
index.searchForFacetValues | → | client.searchForFacetValues |
index.searchRules | → | client.searchRules |
index.searchSynonyms | → | client.searchSynonyms |
index.setSettings | → | client.setSettings |
index.{operation}.wait | → | client.waitForTask |
Recommend API client
| Version 8 (legacy) | Version 9 (current) | |
|---|---|---|
client.getFrequentlyBoughtTogether | → | client.getRecommendations |
client.getRecommendations | → | client.getRecommendations |
client.getRelatedProducts | → | client.getRecommendations |