-1

I tried to build my project in Xcode 11 and it throws 26 identical errors

<unknown>:0: error: '==' is only available in iOS 13.0 or newer 

The errors happen on Compile Swift source files stage upon calling CompileSwift normal arm64 /long/path/to/MyClass.swift .... There is no context help pointing to anything within the files. The files are quite different but look harmless and does not share anything in common.

Zouhair Sassi
  • 1,403
  • 1
  • 13
  • 30
Alexander Vasenin
  • 11,437
  • 4
  • 42
  • 70

1 Answers1

2

After a lot of pain, I found the 4-month old app version compiles fine. So I did git bisect and found the offending commit, and then this code:

struct Config: Equatable {
    let formatDescription: CMFormatDescription
    let orientation: CGImagePropertyOrientation
}

Turns out CMFormatDescription did become Equatable only in iOS 13, while the app deployment target is iOS 11. It probably felt back to [NSObject isEqual:] in Xcode 10, but it became complicated in Xcode 11. Since Swift automatically generates Equatable conformance under the hood it had troubles in pointing the exact place of the error. The solution is to add your own Equatable implementation for CMFormatDescription:

extension CMFormatDescription: Equatable {
    public static func == (lhs: CMFormatDescription, rhs: CMFormatDescription) -> Bool {
        return CMFormatDescriptionEqual(lhs, otherFormatDescription: rhs)
    }
}
Alexander Vasenin
  • 11,437
  • 4
  • 42
  • 70
  • 1
    Maybe also check out [`CMFormatDescriptionEqual(_:otherFormatDescription:)`](https://developer.apple.com/documentation/coremedia/1489825-cmformatdescriptionequal) to see if that suits your needs. – TylerP Nov 01 '19 at 21:44
  • 1
    @TylerTheCompiler Thank you, that's a much better solution! – Alexander Vasenin Nov 02 '19 at 16:28