Multiple errors with the "object capture" GuidedCapture code?

Value of type 'ObjectCaptureSession' has no member '$feedback' Value of type 'ObjectCaptureSession' has no member '$state'

Any thoughts? code is how it came in the .zip

Post not yet marked as solved Up vote post of CluelessA Down vote post of CluelessA
1.3k views

Replies

+1

I am facing the same issue. The code compiled and worked correctly with Xcode 15 beta 2 and ran successfully in iPad OS (17 beta) a week ago.

Now with updated iPad OS 17 beta and latest XCode 15 beta 5, I am seeing the same compilation errors as you are.

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.

I have same issue, did you find any solution? @CluelessA @RadhikaS

Hey @TannazParsa

No luck yet. As @kalgrey mentioned, I followed the code change to fix the listeners per suggestion, and then made the ObjectCaptureSession conform to ObservableObject.

I was able to run the app this time, capture the images in various angles. However, the app crashed when it tried to construct the USDZ file based on the captured images.

+1 Is it possible to get the old working by recompiling with beta 2. I tried it , and not working now. Xcode complier is itself showing error

I tried to run on beta 2 and it compiles and loads onto the phone. It then runs into an error when it runs on the phone and my phone froze completely unresponsive. I had to do a reset the phone with volume up and down.

Same here, tried to compile the code with the latest iPhone OS beta with Xcode beta 2. The app did build up, however, a black-blank screen pop up with nothing responding.

We switched ObjectCaptureSession to use the new Observation (https://developer.apple.com/videos/play/wwdc2023/10149/) feature. Unfortunately, the sample code update was not released at the same time as the API change and we apologize for the inconvenience this caused. The new sample code that switches to the new Observation feature is available now.

As noted, ObjectCaptureSession no longer uses the Combine ObservableObject which means all SwiftUI usage points no longer need @ObservedObject (as the WWDC session above describes). We highly recommend storing the session in a ground truth model class for maximal control of its lifecycle and passing it by reference as needed to SwiftUI views. As the Observation session points out, this change should simplify usage and allow SwiftUI better efficiency in updates. We encourage you to watch the WWDC session on Observation to learn more about the benefits of switching to Observation in your own code.

As part of this change, the implicit Combine publishers for $state and $feedback (and others) that were previously automatically created by conforming to ObservableObject also went away when we dropped this conformance. To replace this functionality, we introduced the new AsyncSequence based ObjectCaptureSession.Updates<T> properties to support apps that want to handle programmatic state updates, like our sample app. Async update loop code can be placed programmatically in Tasks within your app, or attached to .task() view modifiers right in your SwiftUI code to tie their lifecycle to a particular View.

@Graphics and Games Engineer First off, appreciate all the hard work from the dev team as well as for the update.

I'm getting a warning that says "Unknown Part" for the camera and depth data is not being collected by the lidar sensor. I went to the Apple store thinking I needed a repair, but a staff member there told me that it's because I'm running iOS 17 beta (latest version on iPhone 13 Pro Max) and it's likely a calibration bug. Is he right? I can't run the sample code (or any code that uses depth) and could use an assist, please.

I couldn't find a link of sample code, can anybody share please?