> For the complete documentation index, see [llms.txt](https://docs.nubrick.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nubrick.app/guide/ios-api-migration.md).

# iOS API移行ガイド（旧→新）

このページは、旧 iOS API（`NubrickClient` 系）から現行 API（`NubrickSDK` 系）への移行ポイントをまとめたものです。

## 対応表

| 旧API                                         | 新API                                           |
| -------------------------------------------- | ---------------------------------------------- |
| `NubrickClient(projectId: ...)`              | `NubrickSDK.initialize(projectId: ...)`        |
| `nubrick.experiment.dispatch(...)`           | `NubrickSDK.dispatch(...)`                     |
| `nubrick.experiment.embedding(...)`          | `NubrickSDK.embedding(...)`                    |
| `nubrick.experiment.embeddingUIView(...)`    | `NubrickSDK.embeddingUIView(...)`              |
| `nubrick.experiment.remoteConfig(...)`       | `NubrickSDK.remoteConfig(...)`                 |
| `nubrick.experiment.remoteConfigAsView(...)` | `NubrickSDK.remoteConfigAsView(...)`           |
| `nubrick.user.setProperties(...)`            | `NubrickSDK.setUserProperties(...)`            |
| `nubrick.user.id / getProperties()`          | `NubrickSDK.getUserId() / getUserProperties()` |
| `NubrickProvider(client: ...)`               | `NubrickProvider { ... }`                      |
| `AsyncEmbeddingPhase`                        | `SwiftUIEmbeddingPhase`                        |
| `EmbeddingPhase`                             | `UIKitEmbeddingPhase`                          |

## 主要な書き換え例

### 1) 初期化

```swift
// Before
let nubrick = NubrickClient(projectId: "<PROJECT_ID>")

// After
NubrickSDK.initialize(projectId: "<PROJECT_ID>")
```

### 2) SwiftUI での埋め込み

```swift
// Before
nubrick.experiment.embedding("TOP_COMPONENT")

// After
NubrickSDK.embedding("TOP_COMPONENT")
```

### 3) ユーザープロパティ

```swift
// Before
nubrick.user.setProperties(["plan": "gold"])

// After
NubrickSDK.setUserProperties(["plan": "gold"])
```

### 4) Provider

```swift
// Before
NubrickProvider(client: client) {
    ContentView()
}

// After
NubrickProvider {
    ContentView()
}
```

## 注意点

* 旧 `NubrickClient` / `NubrickExperiment` / `NubrickUser` を前提としたコードはそのままでは動きません。
* `ComponentEvent` から `destinationPageId` は削除されています。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nubrick.app/guide/ios-api-migration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
