Skip to content

Ch 7 Activity Recognition - Code will not run fails ContentView.swift #3

@edmtekx

Description

@edmtekx

Ch 7 code compiles and builds fine, however it fails with a run time error in ContentView.swift: (Did not type code in - took it straight from this Git repo)

SwiftUI:0: Fatal error: No ObservableObject of type ActivityTracker found. A View.environmentObject(_:) for ActivityTracker may be missing as an ancestor of this view.

The failure is at this line:
let newActivity = tracker.currentActivity

Built with Xcode 12.5.1 on an Intel MBP machine for iPhone X

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions