簡體   English   中英

Xcode 11 “'==' 僅在 iOS 13.0 或更高版本中可用”錯誤

[英]Xcode 11 “'==' is only available in iOS 13.0 or newer” error

我試圖在 Xcode 11 中構建我的項目,它拋出了 26 個相同的錯誤

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

在調用CompileSwift normal arm64 /long/path/to/MyClass.swift...時,錯誤發生在Compile Swift source files stage 沒有上下文幫助指向文件的任何內容。 這些文件完全不同,但看起來無害,並且沒有任何共同之處。

經過一番痛苦,我發現 4 個月大的應用程序版本編譯正常。 所以我做了git bisect並找到了有問題的提交,然后是這段代碼:

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引擎蓋在指出錯誤的確切位置時遇到了麻煩。 解決方案是為CMFormatDescription添加您自己的Equatable實現:

extension CMFormatDescription: Equatable {
    public static func == (lhs: CMFormatDescription, rhs: CMFormatDescription) -> Bool {
        return CMFormatDescriptionEqual(lhs, otherFormatDescription: rhs)
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM