IOS 13 组合框架 - @Published 不工作 ("Unknown attribute 'Published'")

IOS 13 Combine Framework - @Published not working ("Unknown attribute 'Published'")

我看了 WWDC 2019 session "Combine in Practice" (https://developer.apple.com/videos/play/wwdc2019/721/).

在视频中,他们使用以下语法创建发布者:

@Published var someName: String = ""

他们这样做是为了 someName 成为出版商。但是,Xcode 不喜欢这种语法并给我一个错误:

Unknown attribute 'Published

我不知道为什么。我在 macOS Catalina 上使用 Xcode 11 beta。

有什么想法吗?

来自Xcode 11 Beta Release Notes(强调已添加):

The Foundation integration for the Combine framework is unavailable. The following Foundation and Grand Central Dispatch integrations with Combine are unavailable: KeyValueObserving, NotificationCenter, RunLoop, OperationQueue, Timer, URLSession, DispatchQueue, JSONEncoder, JSONDecoder, PropertyListEncoder, PropertyListDecoder, and the @Published property wrapper. (51241500)


更新: 这已通过 Xcode 11 beta 2 修复。来自 Xcode 11 Beta 2 Release Notes

Resolved Issues

The Foundation integration for the Combine framework is now available. The following Foundation and Grand Central Dispatch integrations with Combine are available: KeyValueObserving, NotificationCenter, RunLoop, OperationQueue, Timer, URLSession, DispatchQueue, JSONEncoder, JSONDecoder, PropertyListEncoder, PropertyListDecoder, and the @Published property wrapper. (51241500)

在 Xcode 11 beta 2 中可用,但必须导入 Combine