'init(frame:)' was deprecated in iOS 26.0: Use init(windowScene:) instead

3 weeks ago 20
ARTICLE AD BOX

I am using this file from swift-snapshot-testing library. After updating my project to iOS 26, I need to fix all the warnings. But I am not sure how to fix this one:

'init(frame:)' was deprecated in iOS 26.0: Use init(windowScene:) instead.

This occurs in:

super.init(frame: .init(origin: .zero, size: size))

from line 1061 of the View.swift file which is linked.

I try to find a keyWindow, but it renders incorrect snapshots, so it's not the right solution. This was what I tried:

let windowScene = UIApplication.shared.connectedScenes .compactMap { $0 as? UIWindowScene } .first { $0.activationState == .foregroundActive } super.init(windowScene: windowScene!)
Read Entire Article