# iOS (Swift) SDK

### Install Using **Swift Package Manager (requires Xcode 12+)**

1. In Xcode, select File > Swift Packages > Add Package Dependency.
2. Paste the URL [`https://github.com/spindl-xyz/spindl-ios/`](https://github.com/spindl-xyz/spindl-ios/) and a minimum semantic version of v1.0.1. You can see in the [tags sections](https://github.com/spindl-xyz/spindl-ios/tags), our latest releases.

### Initialize SDK

Initialize the SDK with your API key upon launching the app, usually in the `AppDelegate`, or `App` protocol implementor:

```swift
import SpindlSDK

struct MyApp : App {

  init() {
    Spindl.initialize("<your API key goes here>")
  }
  
  ...
}
```

### Track Events

Track events with the `track` method:

* `name` is required
* `properties` are optional

```swift
private func myButtonTappedExample() async throws {
    try await Spindl.shared.track(name: "myButtonTapped", properties: ["view":"MyFancyView","otherProperty":"Another one"])
    ...
}
```

### Identify Users

Once customers enter their customer ID (such as email) and/or wallet information (e.g., after logging in), connect that to the analytics by calling the `identify` method of the `Spindl` singleton:

```swift
private func saveUserIdentityExample(wallet: String?, email: String?) async throws {
    try await Spindl.shared.identify(walletAddress: wallet, customerUserId: email)
    ...
}
```


---

# Agent Instructions: 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:

```
GET https://docs.spindl.xyz/spindl/techncial/ios-swift-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
