Xcode 14 beta 错误:存储的属性无法用“@available”标记为可能不可用

bme*_*kle 36 xcode ios swift ios16 xcode14

当我在 Xcode 14 beta 上运行我的应用程序时,出现此错误,但我不知道如何修复它:

存储的属性不能用“@available”标记为可能不可用

当我运行 Xcode 13 时它不会弹出,并且应用程序运行顺利。我在 .xcworkspace 文件中。

Vis*_*hnu 24

我在 XCode 14 的 Flutter 项目中遇到此错误。外部包之一正在使用:

@available(iOS 14.0, *) 我当前的修复是:

Podfile 平台中的更新版本:ios、'14.0'、pod update && Pod install


Sye*_*eed 17

如果此错误是由于DKImagePickerController.

按着这些次序:

  1. 转到您的 Podfile 并将此https://github.com/miguelpruivo/DKImagePickerController.git url 替换为此https://github.com/zhangao0086/DKImagePickerController.git url。
  2. 在您的 flutter 项目中运行以下命令:
    2.1) flutter clean
    2.2)flutter pub get
  3. 导航到 ios 文件夹并运行以下命令:
    3.1) pod installarch -x86_64 pod install如果您使用 M1,则使用)
    3.2) pod updatearch -x86_64 pod update如果您使用 M1,则使用)
  4. 运行您的项目。


kga*_*dis 16

在 Xcode 13 及更低版本中,如果您使用惰性 @available 存储属性,则可以进行编译:

@available(iOS 10.0, *)
private(set) lazy var center = UNUserNotificationCenter.current()
Run Code Online (Sandbox Code Playgroud)

但是,这在 Xcode 14 中不起作用。

相反,您需要使用不可用的存储属性,使用计算的@available 属性:

private var _selectionFeedbackGenerator: Any? = nil
@available(iOS 10.0, *)
fileprivate var selectionFeedbackGenerator: UISelectionFeedbackGenerator {
    if _selectionFeedbackGenerator == nil {
        _selectionFeedbackGenerator = UISelectionFeedbackGenerator()
    }
    return _selectionFeedbackGenerator as! UISelectionFeedbackGenerator
}
Run Code Online (Sandbox Code Playgroud)

答案来源


Iva*_*iuk 13

就我而言,问题出在flutter_inappwebview包中。我已经使用最新版本修复了它 - 5.4.4+3

https://pub.dev/packages/flutter_inappwebview/install

  • 这对我有用,我有“flutter_inappwebview”版本5.3.2,将其更改为5.4.4,“flutter pub get”,它正在工作,谢谢! (3认同)