Swiftpack.co -  johnno1962/HotSwiftUI as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
johnno1962/HotSwiftUI
Utilities for Hot Reloading SwiftUI apps.
.package(url: "https://github.com/johnno1962/HotSwiftUI.git", from: "1.1.2")

HotSwiftUI

Utilitiy methods for use with HotReloading or InjectionIII to make live code updates to fully functional SwiftUI Applictions.

Add this repo to your project and add the following to a source file.

@_exported import HotSwiftUI

This will make the .eraseToAnyView() method on SwiftUI.View used to erase their type available throughout the app along with the global injectionObserver variable you can observe to force the View to update when code has been injected. SwiftUI is very well suited to injection as, provided you observe the injectionObserver which has an @Published injection counter, you can rest assured your views will update as required.

In short, modify the end of your SwiftUI View body properties to look like this:

    var body: some View {
        // Your SwiftUI code...
        .eraseToAnyView()
    }

    #if DEBUG
    @ObservedObject var iO = injectionObserver
    #endif

You need to do this for all view properties you'd like to inject and have refesh on injection which is a bit tedious but the InjectionIII or HotReloading app can make these changes automatically using the "Prepare Project" Menu Item. You can check in these changes as, in a "Release" build, these functions compile to a null operation.

GitHub

link
Stars: 50
Last commit: 5 weeks 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.

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