Skip to content

[Book] 'RustAppWrapper' does not conform to protocol 'ObservableObject' #353

@kshehata

Description

@kshehata

I'm trying to follow the book instructions for XCode + Cargo, and I'm getting the error below.

[...]/ios-rust-analyzer/IosRustAnalyzer/IosRustAnalyzer/IosRustAnalyzerApp.swift:20:7 Type 'RustAppWrapper' does not conform to protocol 'ObservableObject'

Here's the code that seemed to fix it:

import Combine
import SwiftUI

@main
struct IosRustAnalyzerApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .environmentObject(RustAppWrapper(rust: RustApp()))
        }
    }
}

class RustAppWrapper: ObservableObject {
    @Published var rust: RustApp

    init(rust: RustApp) {
        self.rust = rust
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions