nicklockwood / layout

A declarative UI framework for iOS
MIT License
2.23k stars 97 forks source link

Hot reloading does not work for XML not in the main bundle #169

Open ost12666 opened 5 years ago

ost12666 commented 5 years ago

Probably because of this code assumes main bundle:

        let bundlePath = Bundle.main.bundleURL.absoluteString
        if xmlURL.absoluteString.hasPrefix(bundlePath) {

LayoutLoader.swift line 276

ost12666 commented 5 years ago

Also if I run the app from Xcode then I would load the layout XML from the framework bundle successfully but if I am running the app directly from the simulator I get the red screen because XML is not found

elango commented 4 years ago

Hi, I have faced the same issue when creating a universal framework using this library.

This might help someone who encounter the same issue.

One way to fix this is, read the XML content using the bundle and write it temporary or documents folder. Then If you try to access it from the document folder, it works fine.

You can keep a check if the file exists on the documents folder, you can skip writing and pass the path to loadLoayout(withContentsOfUrl: url!, ...)