Xcode 14测试版错误:不能使用“@available”将存储属性标记为可能不可用

ccrfmcuu  于 2022-12-14  发布在  其他
关注(0)|答案(6)|浏览(706)

当我在Xcode 14测试版上运行我的应用程序时,我遇到此错误,但我不知道如何修复它:
不能使用“@available”将存储属性标记为可能不可用
当我运行Xcode 13时,它没有弹出,应用程序运行流畅。我在.xcworkspace文件中。

u4dcyp6a

u4dcyp6a1#

我在XCode 14的Flutter项目中遇到了这个错误。其中一个外部包使用了:
@available(iOS 14.0,*)我当前的修复是:
更新Podfile平台中的版本:ios、“14.0”、Pod更新和Pod安装

ltqd579y

ltqd579y2#

在Xcode 13及更低版本中,如果使用lazy @available stored属性,则可以进行编译,如下所示:

@available(iOS 10.0, *)
private(set) lazy var center = UNUserNotificationCenter.current()

但是,这在Xcode 14中不起作用。
相反,您需要使用不可用的存储属性,* 并 * 使用计算@可用属性:

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

Answer source

8wtpewkr

8wtpewkr3#

在我的情况下,问题是在flutter_inappwebview包。我已经修复它使用最新版本- 5.4.4+3
https://pub.dev/packages/flutter_inappwebview/install

icnyk63a

icnyk63a4#

我也遇到了同样的问题。按照GitHub上的仓库的指示,解决办法是更新Podfile版本:platform :ios, '14.0'

bz4sfanl

bz4sfanl5#

请确保在“构建设置”选项卡中更改iOS部署目标的两个部分,如我的图片所示:

fnatzsnv

fnatzsnv6#

让我告诉你100%工作溶液如果这个错误是由于DKImagePickerController引起的。
请执行下列步骤:
1.后藤您的播客文件,并将此**https://github.com/zhangao0086/DKImagePickerController.giturl替换为此https://github.com/zhangao0086/DKImagePickerController.git**url。
1.在flutter项目中运行以下命令:
2.1)flutter clean
2.2)flutter pub get
1.导航到ios文件夹并运行以下命令:
3.1)pod install(如果使用M1,则使用arch -x86_64 pod install
3.2)pod update(如果使用的是M1,则使用arch -x86_64 pod update
1.运行项目。

相关问题