cozie-app / cozie-apple

https://cozie-apple.app
GNU Lesser General Public License v3.0
15 stars 9 forks source link

Read question flows from JSON file #65

Closed mariofrei closed 1 year ago

mariofrei commented 2 years ago

Is your feature request related to a problem? Please describe. Currently, question flows are hardcoded. Ideally, question flows are read from a JSON file. This is easier to modify and it would allow providing question flows from web sources

Additional context Reading a file is surprisingly difficult to implement in XCode. Below is the read function from the freelancers to start off of. It was part of the code until Build 17 and was in "cozie-apple/Cozie WatchKit Extension/InterfaceController.swift"

    private func readLocalFile(forName name: String) -> Data? {
        do {
            if let bundlePath = Bundle.main.path(forResource: name,
                                                 ofType: "json"),
                let jsonData = try String(contentsOfFile: bundlePath).data(using: .utf8) {
                return jsonData
            }
        } catch {
            print(error)
        }
        return nil
    }
mariofrei commented 1 year ago

This feature has been implemented in Cozie v3