xcodeavplayercmtimeios16.2

Fix "Type 'CMTime' has no member 'zero'" error in Xcode, for 16.2?


It seems that currently (14.2 (14C18)) if you use CMTime.zero

self.player?.seek(to: .zero, toleranceBefore: .zero, toleranceAfter: .zero)

or

self.player?.seek(to: .zero)

you'll see the error

enter image description here

However, the project does compile and run perfectly.

For the file, I import

import UIKit
import CoreMedia
import AVFoundation
import MediaPlayer
import AVKit

(And if I try removing some/all of those it makes no difference; I can't find a fix anyway.)

It seems that if you wind back to minimum deployment 16.0 (rather than current 16.2) the warnings do go away, but the behavior is a bit erratic.

Is anyone familiar with this and/or has a solution?


Solution

  • I had the same issue and tried to delete ~/Library/Developer/Xcode/DerivedData as suggested by the comments, but they didn't work. I was able to fix it by changing the Swift Language Version to Swift 5 in Build Settings. I was using Swift 4 previously.

    enter image description here

    My setup is Xcode 14.2, trying to build to an iPhone with iOS16.1.