Image Playground Error: Cannot find protocol declaration for 'ImageGenerationViewControllerDelegate'

@available(macCatalyst 18.1, *)
@available(iOS 18.1, *)
extension CKImageSelectionManager: ImagePlaygroundViewController.Delegate {
    public func imagePlaygroundViewController(_ imagePlaygroundViewController: ImagePlaygroundViewController, didCreateImageAt imageURL: URL) {
        
    }
    
    func presentImagePlayground() {
        let imagePlaygroundVC = ImagePlaygroundViewController()
        
        // Set delegate to self to receive the callback
        imagePlaygroundVC.delegate = self
        
        imagePlaygroundVC.isModalInPresentation = true // Prevents dismissal with swipe if needed
        
self.delegate?.presentImageSelectionViewController(imagePlaygroundVC)
    }
    
}

This generates an error in the xcode generated swift header.

Answered by DTS Engineer in 818503022

Hi @corkedlabs and @fehners,

Thank you both for sharing in the forums about this and for filing feedback.

As of iOS 18.2, Objective-C projects may encounter compilation issues when accessing Image Playground. In the meantime you can consider creating a private or fileprivate Swift class that adopts ImagePlaygroundViewController.Delegate, and then creating an intermediate protocol to bring the functionality into your Objective-C project.

Keep an eye on future releases for the option to implement Image Playground more directly into your Objective-C project.

Best,

-J

Hi @corkedlabs, are you able to reproduce this error in a focused sample project so we can narrow down where things are going wrong?

Best,

-J

I get this as well. Seems to be due to having a project with a mix of Swift and Objc. FB (9FB16077654) Sample project is attached to that feedback

Hi @corkedlabs and @fehners,

Thank you both for sharing in the forums about this and for filing feedback.

As of iOS 18.2, Objective-C projects may encounter compilation issues when accessing Image Playground. In the meantime you can consider creating a private or fileprivate Swift class that adopts ImagePlaygroundViewController.Delegate, and then creating an intermediate protocol to bring the functionality into your Objective-C project.

Keep an eye on future releases for the option to implement Image Playground more directly into your Objective-C project.

Best,

-J

Image Playground Error: Cannot find protocol declaration for 'ImageGenerationViewControllerDelegate'
 
 
Q