Skip to main content

Getting Started with Swift

Alpha Software

The IOTA SDK is currently in alpha. APIs, interfaces, and behavior may change without notice between releases. It is not yet recommended for production use.

The IOTA SDK Swift bindings allow iOS and macOS developers to build native applications that interact with the IOTA network. These bindings use UniFFI to bridge the Rust core SDK into a native Swift interface.

Prerequisites

Before using the Swift bindings, ensure you have:

  • Xcode: Version 14.0 or higher.
  • Swift: Version 5.7 or higher.
  • macOS: 12.0 or higher (for development).

Installation

Swift Package Manager (SPM)

You can add the IOTA SDK to your project via Swift Package Manager. In Xcode:

  1. Select File > Add Packages...
  2. Enter the repository URL: https://github.com/iotaledger/iota-rust-sdk
  3. In the dependency rule, select the develop branch or a specific version.
  4. Select the IotaSDK library.

Quick Start Example

The following example demonstrates how to connect to the IOTA Testnet and retrieve the Chain ID.

1. Implementation

You can use the following code snippet in your main.swift or within an async task in your app:

bindings/swift/examples/ChainId.swift
loading...
App Sandbox & Permissions

If you are building for macOS or iOS, ensure your app has Outgoing Connections (Client) enabled in the "App Sandbox" or "Hardened Runtime" settings to allow the SDK to communicate with IOTA nodes.

What's Next?

Now that you have connected to the network, you can explore more advanced features:

  • Accounts and Addresses: create a mnemonic, derive addresses, and check coin balances.
  • Transactions: build, sign, and send Programmable Transaction Blocks (PTBs), including staking and reusing command results.
  • Queries: query owned objects, events, and transactions with the GraphQL client.

View more comprehensive examples in the official Swift examples directory.