Why Xcode 16.2 Build Error using Swift 5.0

I have been facing a error in Xcode 16.2 ,

swift-tools-version:5.7 in SPM.

Where we created a Protocol based of AVPlayer functions

public protocol AVPlayerDefinedProtocol: AnyObject {

  func addPeriodicTimeObserver(
        forInterval interval: CMTime,
        queue: DispatchQueue?,
        using block: @escaping (CMTime) -> Void
    ) -> Any

  // Other AvPlayer functions defined here.
  ...
  ..
}

++

import AVFoundation

extension AVPlayer: AVPlayerDefinedProtocol { } //throws error here.
// saying AVPlayer do not conform to AVPlayerDefinedProtocol . @Sendable or @mainActor needed.

I do not face this in Xcode 15.2 , Swift 5.0 . Is there any easy way to get past this.

cc: @Douglas_Gregor , can you please help, Thank you!
I see a help from you Please help me understand the decision to add Swift 6 warnings to Swift 5

I'm not sure why it would be error in Swift 5 language mode ¯\_(ツ)_/¯

FWIW I see a warning with your attached code — you can fix the warning by adding @Sendable to the closure:

using block: @escaping @Sendable (CMTime) -> Void

It looks like AVPlayer was updated in Xcode 16 to require a @Sendable closure here. The docs don't list it, but the Swift interface does...

Hi @swhitty ,
Thanks for your response I added ,
using block: @escaping @Sendable (CMTime) -> Void
But I still get the following error:-

Candidate has non-matching type '(CMTime, @escaping @MainActor @Sendable (Bool) -> Void) -> Void'

I tried to add

using block: @escaping @MainActor @Sendable (CMTime) -> Void

But still it shows error for me.

Exactly, one weird thing I noticed in Xcode 16.2, clean build shows that error(even warnings as error is set to no). If I build it again(without clean build), it passes and I can even load the simulator with the build.