Xcode 11 Beta 3,构建错误“Unknown attribute 'State'",“Use of undeclared type 'View'"等等 [英] Xcode 11 Beta 3, build error "Unknown attribute 'State'", "Use of undeclared type 'View'" etc
问题描述
我使用 Xcode 11 的第二个测试版构建了一个应用程序,使用 SwiftUI,一切正常,但是现在,使用第三个测试版,该应用程序甚至没有构建.我收到诸如使用未声明的类型‘视图’"、未知属性‘状态’"等错误.我该怎么办?是我的代码有问题还是只是一个错误?
I build an app with the 2nd beta of Xcode 11, using SwiftUI, and everything worked completely fine, but now, with the 3rd beta, the app isn't even build. I get errors like "Use of undeclared type 'View'", "Unknown attribute 'State'" etc. What can I do? Is the problem in my code or is it just a bug?
问题是当我尝试构建应用程序以在我的 Mac 上运行时(使用 UIKit for Mac)
@State var score = 0
错误是未知属性'状态'"
The error is "Unknown attribute 'State'"
struct ContentView : View {
/*...*/
}
错误是使用未声明的类型'视图'"
The error is "Use of undeclared type 'View'"
推荐答案
这是来自 Xcode 11Beta 3 发行说明.
- Xcode 11 不支持在引入 macOS 的 iPad 应用中使用 SwiftUI.(41416222, 51201699)
我自己下载了 Xcode 11 Beta 3 只是为了确认您提到的错误,并且在尝试为 Mac 构建 SwiftUI 项目时遇到了同样的问题.
I downloaded the Xcode 11 Beta 3 myself just to confirm the errors you mentioned, and I had the same issues when trying to build a SwiftUI project for Mac.
如果可能,我建议重新使用 Xcode Beta 2.不幸的是,Apple 不提供以前测试版的下载链接,因此希望您的计算机上仍安装有 Time Machine 备份或 Beta 2.否则,在下一个测试版发布之前,您可能会倒霉.
I would suggest going back to using Xcode Beta 2 if possible. Unfortunately, Apple doesn't provide download links to previous betas, so hopefully you have a Time Machine backup or Beta 2 still installed on your computer. Otherwise, you might be out of luck until the next beta is released.
这篇关于Xcode 11 Beta 3,构建错误“Unknown attribute 'State'",“Use of undeclared type 'View'"等等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!