# searchSDK for Swift

Swift 6 · iOS 16+ · macOS 13+ · tvOS 16+ · watchOS 9+ · visionOS 1+. Normalized search through your application's HTTPS gateway.

Canonical: https://searchsdk.dev/docs/sdks/swift
Markdown: https://searchsdk.dev/docs/sdks/swift.md

<a id="install"></a>

## Install from source

Package: `SearchSDK`, version `0.1.0-alpha.1`. This is an alpha source/local-artifact installation. No public registry release or release tag is assumed.

**Get the source**

```bash
git clone https://github.com/Belweave/searchSDK.git
cd searchSDK
# Record this revision with your application's dependency lock.
git rev-parse HEAD
```

**Application dependency configuration**

```swift
// In Package.swift, add the local checkout as a dependency:
.package(name: "SearchSDK", path: "/absolute/path/searchSDK")

// In your target's dependencies:
.product(name: "SearchSDK", package: "SearchSDK")
```

The repository-root SwiftPM manifest exposes SearchSDK. Xcode can also consume the Git repository at a reviewed revision containing that manifest. No release tag is assumed; Linux and Windows are unsupported.

<a id="first-search"></a>

## Call your application gateway

First deploy an [application-owned gateway](https://searchsdk.dev/docs/guides/application-gateway). searchsdk.dev hosts a demonstration playground and documentation MCP service; neither is an application gateway for these SDKs.

**SearchExample.swift**

```swift
import SearchSDK

func searchExample(
    endpoint: String,
    applicationToken: @escaping @Sendable () async throws -> String?
) async throws {
    let search = try SearchClient(
        endpoint: endpoint,
        applicationToken: applicationToken
    )
    let response = try await search.search(
        SearchRequest(query: "SQLite write concurrency", limit: 3)
    )
    for result in response.results {
        print(result.url, result.provenance.provider)
    }
}
```

Pass your exact application-owned HTTPS endpoint and a callback that resolves the current application token. Provider selection and provider keys belong on that server. Cancel the caller's Task to cancel search.

<a id="scope"></a>

## Supported surface and limits

Normalized search through your application's HTTPS gateway.

- Gateway search only. No provider-native operations or client-side provider retry/fallback/cache policy.
- Physical devices and every minimum OS runtime are not covered by the local verification.

Preserve result order, provider-native scores and source provenance. Unknown usage is not zero cost. Cancellation and deadlines cannot undo a request already accepted by a remote system or guarantee exactly-once effects.

<a id="verify"></a>

## Verify without provider keys

**Repository checkout · local checks**

```bash
xcodebuild -version
swift test --package-path packages/swift --scratch-path .local/swift-build --jobs 2
sh packages/swift/Scripts/verify-consumer.sh .local/swift-consumer
```

29 tests on macOS and an iOS simulator; tvOS, watchOS and visionOS simulator builds; extracted SwiftPM consumer.

These are deterministic contract and artifact checks. They do not establish live-provider or account-entitlement verification. Read the package README for precise commands, dependencies and runtime coverage.

<a id="next"></a>

## Continue in your language

- [Swift package reference](https://github.com/Belweave/searchSDK/tree/main/packages/swift#readme): Complete API, errors, streaming, packaging and platform boundaries.
- [Compare SDKs](https://searchsdk.dev/docs/sdks)
- [Gateway protocol and authorization](https://searchsdk.dev/docs/guides/application-gateway)
