[英]XCode compile error: confirmationDialog is only available IOS 15.0 or newer
I'm an apprentice of Swift language and having an online course with tutorials.我是 Swift 语言的学徒,并且有一个带教程的在线课程。
While I was coding along with the instructor there was this "confirmationDialog is only available IOS 15.0 or newer."当我和讲师一起编码时,有这个“confirmationDialog 仅适用于 IOS 15.0 或更高版本”。 error presented.出现错误。 I had to write if #available(iOS 15.0, *)
as compiler suggested.我必须按照编译器的建议编写if #available(iOS 15.0, *)
。 However the instructors compiler did not present the same error and she did not make any changes on her code.然而,讲师的编译器并没有出现同样的错误,她也没有对她的代码进行任何更改。
My question is that why the above mentioned error occured on my compiler but not on the instructors?我的问题是为什么上面提到的错误发生在我的编译器上而不是讲师身上? and how can I get rid of this error without adding if #available(iOS 15.0, *)
?以及如何在不添加if #available(iOS 15.0, *)
的情况下摆脱此错误?
Thank you in advance.先感谢您。
The reason for the difference in your environment vs your instructors is that your instructor has their "deployment target" set to iOS 15 and yours is set to something lower like iOS 14 or 13. The deployment target setting governs the minimum version of iOS that your app is allowed to run on.您的环境与您的讲师之间存在差异的原因是您的讲师将他们的“部署目标”设置为 iOS 15,而您的设置为更低的值,例如 iOS 14 或 13。部署目标设置管理您的 Z1BDF605989204 的最低版本 Z1BDF605999204允许应用程序运行。 Your instructor's app can only run on iOS 15 and later, so they don't need to use if #available(iOS 15.0, *)
.您的讲师的应用程序只能在 iOS 15 及更高版本上运行,因此他们不需要使用if #available(iOS 15.0, *)
。 This condition would always be true for them.这种情况对他们来说永远是正确的。 In your case, since your app supports iOS 14, there are some scenarios where the confirmationDialog
API will not be available to the user (since it was added in iOS 15), which is why you need the check.在您的情况下,由于您的应用程序支持 iOS 14,因此在某些情况下,用户无法使用confirmationDialog
对话框 API(因为它已添加到 iOS 15 中,这就是您需要的原因) If you are okay with using a minimum version of iOS 15 like your instructor, you can change this setting in Xcode.如果您可以像您的讲师一样使用最低版本的 iOS 15,您可以在 Xcode 中更改此设置。 Click your project name in the project navigator, click your app target, then click the "General" tab.在项目导航器中单击您的项目名称,单击您的应用程序目标,然后单击“常规”选项卡。 You should see an area called "Deployment Info" and a dropdown for the iOS version.您应该看到一个名为“部署信息”的区域和一个 iOS 版本的下拉列表。 Change this to iOS 15.将此更改为 iOS 15。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.