How to Share and Access Dynamically Updating Data Across Different Targets?

I have a app with two targets: a main DeviceActivityApp target and a DeviceReport target. In the DeviceReport target, I have a TotalActivityReport struct conforming to DeviceActivityReportScene. Inside its makeConfiguration method, I update a dynamically generated list of AppReport items. The list updates correctly in the DeviceReport target.

    // Define which context your scene will represent.
    let context: DeviceActivityReport.Context = .totalActivity
    
    // Define the custom configuration and the resulting view for this report.
    let content: (MonitorDeviceReport) -> TotalActivityViewFirst
    @ObservedObject var activityData:ActivityData
    func makeConfiguration(representing data: DeviceActivityResults<DeviceActivityData>) async -> MonitorDeviceReport {
        // Reformat the data into a configuration that can be used to create
        // the report's view.
        var appList:[AppsReport]=[]
        let totalActivityDuration = await data.flatMap { $0.activitySegments }.reduce(0, {
            $0 + $1.totalActivityDuration
        })
        for await _data in data{
            for await activity in _data.activitySegments{
                for await category in activity.categories{
                    for await app in category.applications{
                        let name=app.application.localizedDisplayName ?? "No Name"
                        let bundleId=app.application.bundleIdentifier ?? "nil"
                        let duration=app.totalActivityDuration
                        let appIcon=app.application.token
                        let app=AppsReport(id:bundleId,duration:duration, name:name, icon:appIcon)
                        appList.append(app)
                        
                    }
                }
            }
        }
        DispatchQueue.main.async {
            activityData.list=appList
        }
        return MonitorDeviceReport(duration:totalActivityDuration, apps:appList)
    }
}

public class ActivityData:ObservableObject{
    @Published var list:[AppsReport]=[]
    public static let shared = ActivityData()
}. // This is in MonitorReport target

However, I need to access this dynamic list in my MyApp target, specifically in ContentView.swift. I tried using an ObservableObject (ActivityData) to share the data between targets, but the list always appears empty in the MyApp target.

Here’s what I’ve tried so far:

  1. Created a shared ActivityData instance using @Published
  2. Passed the ActivityData instance to TotalActivityReport
  3. Used dependency injection and a singleton pattern for ActivityData
  4. Verified that makeConfiguration updates the list correctly in DeviceReport

What could I be missing? How can I correctly share and access this data across targets?

How to Share and Access Dynamically Updating Data Across Different Targets?
 
 
Q