> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upgrading InstantSearch iOS

> Upgrade your InstantSearch iOS version

export const FlavorSwitcher = ({current, baseHref = "", options = [], label = "InstantSearch framework"}) => {
  if (options.length === 0) {
    return <div className="not-prose" role="alert" style={{
      margin: "0.25rem 0 1.5rem",
      padding: "0.75rem",
      border: "1px solid #f59e0b",
      borderRadius: "0.625rem",
      color: "inherit",
      fontSize: "0.875rem"
    }}>
        FlavorSwitcher requires at least one option.
      </div>;
  }
  const selected = options.find(option => option.value === current) ?? options[0];
  return <div className="not-prose mint-flavor-switcher">
      <style>{`
        .mint-flavor-switcher {
          --mfs-bg: #ffffff;
          --mfs-bg-hover: #f4f4f5;
          --mfs-bg-current: #eef2ff;
          --mfs-border: #d4d4d8;
          --mfs-fg: #18181b;
          --mfs-muted: #71717a;
          --mfs-accent: #4f46e5;
          position: relative;
          width: min(100%, 19rem);
          margin: 0.25rem 0 1.5rem;
          color: var(--mfs-fg);
          font-size: 0.875rem;
          line-height: 1.25rem;
        }

        .dark .mint-flavor-switcher {
          --mfs-bg: #18181b;
          --mfs-bg-hover: #27272a;
          --mfs-bg-current: #272747;
          --mfs-border: #3f3f46;
          --mfs-fg: #fafafa;
          --mfs-muted: #a1a1aa;
          --mfs-accent: #a5b4fc;
        }

        .mint-flavor-switcher details {
          position: relative;
        }

        .mint-flavor-switcher summary {
          display: flex;
          min-height: 2.75rem;
          box-sizing: border-box;
          align-items: center;
          justify-content: space-between;
          gap: 0.75rem;
          padding: 0.625rem 0.75rem;
          border: 1px solid var(--mfs-border);
          border-radius: 0.625rem;
          background: var(--mfs-bg);
          color: var(--mfs-fg);
          cursor: pointer;
          font-weight: 600;
          list-style: none;
          transition: border-color 150ms ease, box-shadow 150ms ease;
        }

        .mint-flavor-switcher summary::-webkit-details-marker {
          display: none;
        }

        .mint-flavor-switcher summary:hover {
          border-color: var(--mfs-accent);
        }

        .mint-flavor-switcher summary:focus-visible {
          outline: 2px solid var(--mfs-accent);
          outline-offset: 2px;
        }

        .mint-flavor-switcher__label {
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }

        .mint-flavor-switcher__chevron {
          flex: none;
          transition: transform 150ms ease;
        }

        .mint-flavor-switcher details[open] .mint-flavor-switcher__chevron {
          transform: rotate(180deg);
        }

        .mint-flavor-switcher__menu {
          position: absolute;
          z-index: 50;
          top: calc(100% + 0.375rem);
          left: 0;
          width: 100%;
          box-sizing: border-box;
          margin: 0;
          padding: 0.375rem;
          border: 1px solid var(--mfs-border);
          border-radius: 0.625rem;
          background: var(--mfs-bg);
          box-shadow: 0 12px 30px rgb(0 0 0 / 16%);
          list-style: none;
        }

        .mint-flavor-switcher__menu li {
          margin: 0;
          padding: 0;
        }

        .mint-flavor-switcher__option {
          display: grid;
          gap: 0.125rem;
          padding: 0.625rem 0.75rem;
          border-radius: 0.4rem;
          color: var(--mfs-fg);
          text-decoration: none;
        }

        .mint-flavor-switcher__option:hover {
          background: var(--mfs-bg-hover);
        }

        .mint-flavor-switcher__option:focus-visible {
          outline: 2px solid var(--mfs-accent);
          outline-offset: -2px;
        }

        .mint-flavor-switcher__option[aria-current="page"] {
          background: var(--mfs-bg-current);
          color: var(--mfs-accent);
        }

        .mint-flavor-switcher__name {
          font-weight: 600;
        }

        .mint-flavor-switcher__description {
          color: var(--mfs-muted);
          font-size: 0.8125rem;
        }

        @media (prefers-reduced-motion: reduce) {
          .mint-flavor-switcher summary,
          .mint-flavor-switcher__chevron {
            transition: none;
          }
        }
      `}</style>

      <details>
        <summary aria-label={`${label}: ${selected.label}`}>
          <span className="mint-flavor-switcher__label">{selected.label}</span>
          <svg className="mint-flavor-switcher__chevron" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
            <path d="m6 9 6 6 6-6" />
          </svg>
        </summary>

        <ul className="mint-flavor-switcher__menu" aria-label={label}>
          {options.map(option => {
    const isCurrent = option.value === selected.value;
    const href = option.href ?? `${baseHref.replace(/\/$/, "")}/${encodeURIComponent(option.value)}`;
    return <li key={option.value}>
                <a className="mint-flavor-switcher__option" href={href} aria-current={isCurrent ? "page" : undefined}>
                  <span className="mint-flavor-switcher__name">
                    {option.label}
                  </span>
                  {option.description ? <span className="mint-flavor-switcher__description">
                      {option.description}
                    </span> : null}
                </a>
              </li>;
  })}
        </ul>
      </details>
    </div>;
};

<div className="mint-flavor-switcher-slot not-prose">
  <FlavorSwitcher
    current="ios"
    baseHref="/doc/guides/building-search-ui/upgrade-guides"
    options={[
{ value: "js", label: "JavaScript", description: "InstantSearch.js" },
{ value: "react", label: "React", description: "React InstantSearch" },
{ value: "vue", label: "Vue", description: "Vue InstantSearch" },
{ value: "ios", label: "iOS", description: "InstantSearch iOS" },
{ value: "android", label: "Android", description: "InstantSearch Android" },
]}
  />
</div>

<Info>
  Starting May 1, 2024,
  Apple requires all iOS apps to include a privacy manifest.
  For more information, see [Privacy manifest](/doc/guides/building-search-ui/resources/privacy-manifest/ios/).
</Info>

## Upgrade to InstantSearch iOS v8

InstantSearch iOS v8 migrates the underlying Algolia client from v8 to the [Algolia Swift API Client v9](https://github.com/algolia/algoliasearch-client-swift).
This introduces several breaking changes.

### Update dependencies

<Tabs>
  <Tab title="Swift Package Manager">
    Update your `Package.swift` dependency:

    ```swift Swift icon=code theme={"system"}
    .package(url: "https://github.com/algolia/instantsearch-ios", from: "8.0.0")
    ```
  </Tab>

  <Tab title="CocoaPods">
    Update your `Podfile`:

    ```ruby Podfile theme={"system"}
    pod("InstantSearch", "~> 8.0")
    ```

    Run `pod update`.
  </Tab>
</Tabs>

### Handle throwing initializers

Searcher convenience initializers that accept `appID` and `apiKey` strings now throw errors because `SearchClient(appID:apiKey:)` throws in the Algolia Swift API Client v9. This applies to `HitsSearcher`, `FacetSearcher`, `MultiIndexSearcher`, and `MultiSearcher`.

<CodeGroup>
  ```swift Before v7 theme={"system"}
  let searcher = HitsSearcher(appID: "ALGOLIA_APPLICATION_ID",
                              apiKey: "ALGOLIA_API_KEY",
                              indexName: "INDEX_NAME")
  ```

  ```swift Before v8 theme={"system"}
  let searcher = try HitsSearcher(appID: "ALGOLIA_APPLICATION_ID",
                                  apiKey: "ALGOLIA_API_KEY",
                                  indexName: "INDEX_NAME")
  ```
</CodeGroup>

Alternatively, create the `SearchClient` yourself and use the non-throwing initializer:

```swift Swift icon=code theme={"system"}
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
                              apiKey: "ALGOLIA_API_KEY")
let searcher = HitsSearcher(client: client, indexName: "INDEX_NAME")
```

### Remove answers and places usage

InstantSearch iOS removed `AnswersSearcher` and `PlacesSearcher` (including their services and connectors) because Algolia Answers and Algolia Places are no longer available.
Remove code that references these types.

* `AnswersSearcher`, `AlgoliaAnswersSearchService`, `AnswersSearcher+FilterState`
* `PlacesSearcher`, `AlgoliaPlacesSearchService`, `Hit+Place`, `HitsConnector+GeoSearch`
* `IndexSegmentInteractor+AnswersSearcher`

### Adapt to new query types

The query parameter type has changed from the v8 client's `Query` to `SearchSearchParamsObject` from the v9 client.
If you set query parameters directly,
update your code to use `SearchSearchParamsObject`.

### Use the local `Hit` type

The `Hit` type is now defined locally in InstantSearchCore rather than being re-exported from the API client.
If you reference `Hit` from the Algolia client module, update your imports.
A SearchHit type alias for `Hit<[String: AnyCodable]>` is available for convenience.

## Update event tracking

**Starting from v7.26.2,
InstantSearch makes it easier to send view events using the [`isAutoSendingHitsViewEvents`](/doc/api-reference/widgets/instantsearch/ios#param-is-auto-sending-hits-view-events) option** on [`HitsSearcher`](/doc/api-reference/widgets/instantsearch/ios#hitssearcher):

```swift Swift icon=code theme={"system"}
let searcher = HitsSearcher(appId: "ALGOLIA_APPLICATION_ID",
                            apiKey: "ALGOLIA_SEARCH_API_KEY",
                            index: "indexName",
                            isAutoSendingHitsViewEvents: true)
```

<Warning>
  From v7.24.0 to v7.26.1, view events were sent automatically.
  Ensure you're using the latest version of InstantSearch to send the required events.
</Warning>

## Upgrade to InstantSearch iOS v5

InstantSearch v5 introduces a new architecture and new widgets,
which brings several breaking changes from the previous versions:

* **No `InstantSearch` component** to automatically connecting widgets.
  You are now in control of the `Searcher` and responsible for connecting and disconnecting it from widgets and other components.

* Widgets are now **built around an `Interactor`**,
  which holds their data and business logic.

  In previous versions, widgets were iOS `UIViews`.
  Now the core of a widget is its interactor.
  The widget's UI is behind an interface to minimize coupling.

To learn more, see:

* [What is InstantSearch iOS](/doc/guides/building-search-ui/what-is-instantsearch/ios)
* [Get started](/doc/guides/building-search-ui/getting-started/ios)

<Info>
  The InstantSearch iOS v3 documentation is available on the [legacy docs page](https://algolia.com/old-docs/deprecated/instantsearch/ios/v3/api-ref/api-ref/).
</Info>
