A package that allows you to easily enable the Xcode canvas to a UIKit view.

Overview

UIViewCanvas

This package allows you to enable a SwiftUI Xcode canva to a UIView or a entire ViewController.

Why?

Run emulator everytime you need to test a small change in your View is painfull.

Requirements

✓ Xcode 11+
✓ Swift 4.2+
✓ iOS 13+ project

How to use?

Step 1

Select your project on Xcode and go to Files > Add Packages and paste this repository URL https://github.com/outrowender/UIViewCanvas on search field.

Select a version and click Install.

Step 2

Add the previewer to the end of your view file:

import SwiftUI
import UIViewCanvas

struct MyPreview: PreviewProvider {
    static var previews: some View {
        ViewCanvas(for: MyCustomUIView())
    }
}

You can instantiate a entire ViewController as well, using ViewControllerCanvas:

struct MyPreview: PreviewProvider {
    static var previews: some View {
        ViewControllerCanvas(for: MyViewController())
    }
}

If you want to customize your preview, check Group component and use a .previewLayout to set a custom canvas to your preview.

struct MyPreview: PreviewProvider {
    static var previews: some View {
        Group{
            ViewCanvas(for: MyCustomUIView())
        }
        .previewLayout(.fixed(width: 350, height: 350))
    }
}

Step 3

You may need to reopen your .swift file in Xcode.

You can use ⌥ + ⌘ + P to quickly resume your canvas.

Credits

This package was a insight that I got from a @bhlvoong video.

You might also like...
A simple and lightweight Swift package which provides a SwiftUI view for interactive geo coordinates input!
A simple and lightweight Swift package which provides a SwiftUI view for interactive geo coordinates input!

LocationPicker for SwiftUI LocationPicker for SwiftUI is a very simple and lightweight Swift package which provides you a SwiftUI view for interactive

Are you bored? This app helps find you something to do via Bored api
Are you bored? This app helps find you something to do via Bored api

Bored Swift Are you bored? This app helps find you something to do via Bored api Features Beautiful widgets 📅 Simple and easy ✅ Open source 📱 Previe

MapApp - You can save the location of the places you go on the map and add names and notes
MapApp - You can save the location of the places you go on the map and add names and notes

MapApp - You can save the location of the places you go on the map and add names and notes

Bookworm - Track which books you’ve read and what you thought of them
Bookworm - Track which books you’ve read and what you thought of them

Bookworm Description: Bookworm is an app I built while following 100 Days of Swi

A beautiful app that will let you know how much sun you have today.
A beautiful app that will let you know how much sun you have today.

Daylight A beautiful app that will let you know how much sun you have today. Running the project Open Project.xcodeproj and run What's interesting abo

A SwiftUI view that enables you to properly present a UIActivityViewController. (iOS)

ActivityView Also available as a part of my SwiftUI+ Collection – just add it to Xcode 13+ A SwiftUI view that enables you to properly present a UIAct

content for Using Combine - notes on learning Combine with UIKit and SwiftUI
content for Using Combine - notes on learning Combine with UIKit and SwiftUI

SwiftUI-Notes A collection of notes, project pieces, playgrounds and ideas on learning and using SwiftUI and Combine. Changes, corrections, and feedba

Porting the example app from our Advanced iOS App Architecture book from UIKit to SwiftUI.

SwiftUI example app: Koober We're porting the example app from our Advanced iOS App Architecture book from UIKit to SwiftUI and we are sharing the cod

UIKit (MVC), Weather App
UIKit (MVC), Weather App

Weather Simple weather app written on UIKit (MVC) Was used • UITableView • CoreLocation • Lottie Animations • OpenWeatherMap (API) • Author of animate

Owner
Wender
Maybe I'm a ghost.
Wender
Timetinerary is an iOS app that allows you to create, save, and share continuous schedules.

Timetinerary is an iOS app that allows you to create, save, and share continuous schedules. These schedules can be converted into a widget and notifications.

Ben Koppe 1 Feb 14, 2022
An iOS app that allows you to create resumes on your phone and export them to pdf

Resume Builder iOS An iOS app that allows you to create resumes on your phone and export them to pdf To create a new resume, choose + from the main vi

Sonia Grzywocz 1 Oct 25, 2021
iOS app that allows you to search for any comic character and save your favorites in a list.

iOS App: My Comics Swift exercise ¡Hola mundo! In my Swift learning journey my mentor and I decided to do an app using the Comic Vine API. This API gi

Silvia España Gil 5 Dec 13, 2022
The ToDoList application using FireBase allows you to register users

ToDoFirebase Приложение ToDoList с использовавнием FireBase позволяет зарегистри

Vasiliy Chistyakov 0 Dec 19, 2021
Red Torch is a very very (very) simple iOS app that allows you to have a red torch using your screen.

RED Torch Red Torch is a very very (very) simple iOS app that allows you to have a red torch using your screen. The App is based on storyboard, so the

Jakub 0 Jan 1, 2022
A open source Swift app for iOS 13 that allows you to check your NFC transit card information. Written with SwiftUI.

ABANDONED Metrodroid, which TransitPal was heavily inspired by, now has its own fully functional iOS app! It should be in the App Store "soon". I stro

Robbie Trencheny 132 Jun 30, 2022
An iOS AR app that allows you to walk in the International Space Station

AR Inside International Space Station (ISS) An iOS AR app that allows you to walk in the International Space Station. Xcode 13.2.1 Target: iOS / iPadO

Yasuhito Nagatomo 33 Dec 23, 2022
Cookbook app that allows you to read, add and modify your recipes.

What-s-For-Dinner-iOS-App Cookbook app that allows you to read, add and modify your recipes. Features ?? ?? View You can see recipes divided into cate

Katie Saramutina 2 May 18, 2022
A SwiftUI app that reads iOS/watchOS/tvOS device model information from Xcode you select.

iVariant A SwiftUI app that reads iOS/watchOS/tvOS device model information from Xcode you select. Preview License iVariant is licensed under MIT. Cop

Lakr Aream 20 Aug 4, 2022
In this tutorial, you’ll write your very first Core Data application with SwiftUI in Xcode

TodoApp-IOS In this tutorial, you’ll write your very first Core Data application with SwiftUI in Xcode. You’ll see how easy it is to get started with

Noye Samuel 1 Dec 13, 2021