---
title: Visual Preview in Apple
description: Enhance your editorial experience by previewing draft content in an Apple app.
url: https://www.storyblok.com/docs/guides/apple/visual-preview
---

# Visual Preview in Apple

Enhance your editorial and development experience by previewing draft content in the debug build of your Apple app.

## Set version based on build config

Replace the following in `ExampleApp.swift` to set `version` based on the build configuration.

Example/ExampleApp.swift

```swift
…
    private let client = StoryblokClient(
        library: Block.self,
        accessToken: "YOUR_ACCESS_TOKEN",
        version: .draft,
        version: {
            #if DEBUG
            .draft
            #else
            .published
            #endif
        }(),
        region: .eu // Choose the correct region from your Space.
    )
…
```

With these changes, debug builds of the app now fetch draft content from Storyblok, while release builds fetch published content.

## Refresh draft content

With `version` set to `.draft`, any changes you save in Storyblok appear the next time the [`story()`](https://storyblok.github.io/storyblok-swift/documentation/storyblokclient/storyblokclient) publisher is subscribed.

Add the following in `ExampleApp.swift` for a pull-to-refresh implementation so the story can be refreshed without restarting the app.

Example/ExampleApp.swift

```swift
…
    var body: some Scene {
        WindowGroup {
            ScrollView {
                if let story {
                    story.content
                } else {
                    ProgressView()
                        .progressViewStyle(.circular)
                        .frame(maxWidth: .infinity, minHeight: 200)
                }
            }
            .onReceive(publisher) { value in story = value }
            .refreshable {
                for await value in publisher.values {
                    story = value
                }
            }
        }
    }
…
```

The [`story()`](https://storyblok.github.io/storyblok-swift/documentation/storyblokclient/storyblokclient) publisher is now subscribed as follows:

-   The existing `onReceive` modifier subscribes when the view appears to trigger the initial load automatically.
-   The new [`refreshable`](https://developer.apple.com/documentation/swiftui/view/refreshable\(action:\)) modifier adds pull-to-refresh behavior to the scroll view, re-subscribing to the publisher through its [`values`](https://developer.apple.com/documentation/combine/publisher/values-1dm9r) sequence when the user pulls down.
-   Iterating the sequence with `for await` keeps the refresh indicator visible until the request completes, updating the story with the fresh value from the network.

With this in place, make a change to the `home` story, save it, then pull down in the debug build to immediately see the updated draft content.

## Related resources

[Storyblok Swift Client SDK Reference](https://storyblok.github.io/storyblok-swift/documentation/storyblokclient)

[Content Delivery API: Retrieve a Single Story](/docs/api/content-delivery/v2/stories/retrieve-a-single-story)

[Apple Developer: Pull to Refresh in SwiftUI](https://developer.apple.com/documentation/swiftui/view/refreshable\(action:\))

## Pagination

-   [Previous: Integrate Apple with Storyblok](/docs/guides/apple)
-   [Next: Dynamic Navigation in Apple](/docs/guides/apple/dynamic-routing)
