Regarding the errors about $feedback and $state, the implementation of the ObjectCaptureSession was changed to use the AsyncSequence protocol instead of the original Combine publishers. The AsyncSequences I'm referring to are stored under two new properties called feedbackUpdates and stateUpdates, respectively. Here are the changes I made to fix those two errors:
private var subscriptions = Set<Task<(), Never>>()
@MainActor
private func attachListeners() {
logger.debug("Attaching listeners...")
guard let model = objectCaptureSession else {
fatalError("Logic error")
}
let feedbackUpdatesTask = Task { [weak self] in
for await newFeedback in model.feedbackUpdates {
self?.updateFeedbackMessages(for: newFeedback)
}
}
subscriptions.insert(feedbackUpdatesTask)
let stateUpdatesTask = Task { [weak self] in
for await newState in model.stateUpdates {
self?.onStateChanged(newState: newState)
}
}
subscriptions.insert(stateUpdatesTask)
}
private func detachListeners() {
logger.debug("Detaching listeners...")
for sub in subscriptions {
sub.cancel()
}
subscriptions = Set<Task<(), Never>>()
}
The other errors, however, are much more annoying. ObjectCaptureSession is no longer an ObservableObject, so the entire app has to be reworked to account for that shift. I refactored it to access it directly from the appModel EnvironmentObject instead and the app ran, but the reconstruction phase crashed, so I think getting the demo app might require a rewrite to make sure that the code doesn't depend on the session being an observed object. My guess is that's what the Apple dev team is currently doing since I can't find the demo app in the docs table of contents right now (though the link is still accessible). I just wish they'd be more transparent about these things with alerts in the docs above the sample code instead of simply hiding the links.
Topic:
App & System Services
SubTopic:
Core OS
Tags: