---
title: iOS
description: iOS Platform Guide
---

import { Code } from '@astrojs/starlight/components';
import Link from '@slint/common-files/src/components/Link.astro';
import { Image } from 'astro:assets';

:::note[Note]
When developing Slint applications for iOS, you can only use Rust as the programming language.
:::

A Rust-based Slint application can be cross-compiled to iOS and runs on iPhones, iPads, and their
respective simulators. This is implemented through the <Link type="WinitBackend" label="Winit backend" /> and the
<Link type="skia_renderer" label="Skia Renderer" />.

## Prerequisites

 * A computer running macOS.
 * An up-to-date installation of [Xcode](https://developer.apple.com/xcode/).
 * [Xcodegen](https://github.com/yonaskolb/XcodeGen?tab=readme-ov-file#installing).
 * [Rust](https://rustup.rs)
 * The Rust device and simulator toolchains. Run `rustup target add aarch64-apple-ios` and `rustup target add aarch64-apple-ios-sim`
   to add them.

## Adding iOS Support to an existing Rust Application

The following steps assume that you have a Rust application with Slint prepared. If you're just getting started, use our [Slint Rust Template](https://github.com/slint-ui/slint-rust-template)
to get a minimal application running.

Use XCode to building, deploy, and submit iOS applications to the App Store.
Use [Xcodegen](https://github.com/yonaskolb/XcodeGen) to create an Xcode project from a minimal description.

1. Verify that your application compiles for iOS, by running:

```bash
cargo build --target=aarch64-apple-ios
```

2. Create a file called `project.yml` with the following contents:

```yml
name: My App
options:
  bundleIdPrefix: com.company
settings:
  ENABLE_USER_SCRIPT_SANDBOXING: NO
targets:
  MyApp:
    type: application
    platform: iOS
    deploymentTarget: "12.0"
    info:
        path: Info.plist
        properties:
            UILaunchScreen:
                - ImageRespectSafeAreaInsets: false
    sources: []
    postCompileScripts:
      - script: |
          ./build_for_ios_with_cargo.bash slint-rust-template
        outputFileLists:
            $TARGET_BUILD_DIR/$EXECUTABLE_PATH
```

Adjust the name, bundle id, and other fields as needed.

This configuration file delegates the build process to cargo through a shell script.

:::note[Note]
The shell script is invoked with the name of the binary that cargo produces. Update it to match the name of your project.
:::

2. In a new file called `build_for_ios_with_cargo.bash`, paste the following script code:

import scriptContent from './../../../../../../../../scripts/build_for_ios_with_cargo.bash?raw'

<Code code={scriptContent} lang="bash" />

3. Make the script executable with `chmod +x build_for_ios_with_cargo.bash`.

4. Run `xcodegen` to create `My App.xcodeproj`, and open it in Xcode. Now you can build, deploy, and debug your iOS application.

import iosScreenshot from '/src/assets/ios-simulator.webp';

<Image src={iosScreenshot} style={{width: "500px"}} alt="Screenshot Slint Template running in iOS Simulator"  />
