NOTE: I have read the following answer and still did not get how to get rid of the warning.
I am trying to take a screenshot and using the following extensions:
import Photos
extension UIApplication {
    func takeScreenshot() -> UIImage? {
        guard let window = keyWindow else { return nil }
        UIGraphicsBeginImageContextWithOptions(window.bounds.size, false, UIScreen.main.scale)
        window.drawHierarchy(in: window.bounds, afterScreenUpdates: true)
        let screenshot = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return screenshot
    }
}
and this is how I use it:
struct Specials2: View {
    @State private var screenshot: UIImage?
    @State private var showingAlert = false
    var body: some View {
        Button(action: {
            if let takenScreenshot = UIApplication.shared.takeScreenshot() {
                screenshot = takenScreenshot
                print("Screenshot taken")
                UIImageWriteToSavedPhotosAlbum(screenshot!, nil, nil, nil)
                showingAlert = true
            }
            else {
                print("Failed to take screenshot")
            }
        }, label: {
            Image(systemName: "camera.circle")
            
        })
        .alert(isPresented: $showingAlert) {
            Alert(title: Text("Screenshot saved"), message: Text("The screenshot has been saved successfully in your Photos."), dismissButton: .default(Text("OK")))
        }
    }
}
So my question is how to get rid of this very annoying warning?
 
    