I'm testing our app on the release candidate of Xcode 14 and while the app builds ok at runtime I get:
Fatal error: UIViewRepresentables must be value types: PlayerView
PlayerView is a class that handles an onload video - it has a published property and publishers that reference self (I'm quite new to iOS dev so haven't done much with combine) - it was obviously intended to be a class
The UIViewRepresentable protocol is handled like this:
extension PlayerView: UIViewRepresentable { public func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<PlayerView>) { } public func makeUIView(context: Context) -> UIView { return PlayerUIView(frame: .zero, player: player) } } private class PlayerUIView: UIView { private let playerLayer = AVPlayerLayer() init(frame: CGRect, player: AVPlayer) { super.init(frame: frame) playerLayer.player = player playerLayer.videoGravity = .resizeAspectFill layer.addSublayer(playerLayer) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func layoutSubviews() { super.layoutSubviews() playerLayer.frame = bounds } }
Obviously this isn't the final release of Xcode 14 but does anyone know if this is a change in iOS 16 that means we'll have to make this a struct?
Thanks!