Swiftpack.co -  nicoelayda/UIKitLivePreview as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Xcode live previews for UIKit.
.package(url: "https://github.com/nicoelayda/UIKitLivePreview.git", from: "v1.2.0")


Enables SwiftUI live previews for UIKit views and view controllers.



  • macOS Catalina or later
  • Xcode 12 or later
  • iOS Deployment Target 12.0 or later


Swift Package Manager (Recommended)

In Xcode, select File > Swift Packages > Add Package Dependency...

Add https://github.com/nicoelayda/UIKitLivePreview.git as the package repository URL.


If you have an existing Package.swift file, add UIKitLivePreview package to your target's dependencies.

dependencies: [
    .package(url: "https://github.com/nicoelayda/UIKitLivePreview.git", .upToNextMajor(from: "1.2.0"))


  1. Add UIKitLivePreview to your Cartfile.

    github "nicoelayda/UIKitLivePreview" ~> 1.2.0
  2. Run carthage update --use-xcframeworks

  3. Drag UIKitLivePreview.xcframework in Carthage/Build into your application target's Frameworks, Libraries and Embedded Content.


  1. Add UIKitLivePreview to your Podfile.

    pod 'UIKitLivePreview', '~> 1.2.0'
  2. Run pod install

Manual Install

Copy the contents of Sources/UIKitLivePreview to your project.

A prebuilt XCFramework binary is also available


  1. Import UIKitLivePreview in your view or view controller.
  2. In the same Swift file, define a new struct conforming to PreviewProvider.
  3. Inside the previews property:
    • Initialise your UIKit view or view controller.
    • Call preview() on it to create a wrapped SwiftUI View instance.
    • Return the preview instance.
  4. Optionally, you may chain ViewModifiers to customise the preview. See example below.


final class MyViewController: UIViewController { /* ... */ }

#if DEBUG && canImport(SwiftUI)
import SwiftUI

@available(iOS 13.0, *)
struct MyViewController_Preview: PreviewProvider {
    static var previews: some View {

NOTE: If your project is targeting iOS 12, it is recommended to wrap the PreviewProvider struct in a #if canImport(SwiftUI) directive and add the @available(iOS 13.0, *) attribute to it.

Check out UIKitLivePreview-Examples for a sample project.




Stars: 3
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

1 week ago

What's New

Added DeviceModifier for customising the preview.

Check out the latest example project to see how it's used.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API