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

微笑、不失礼 提交于 2019-12-08 16:10:29

问题


I watched the WWDC 2019 session "Combine in Practice" (https://developer.apple.com/videos/play/wwdc2019/721/).

In the video they used the following syntax to create a publisher:

@Published var someName: String = ""

They did this so that someName becomes a publisher. However, Xcode doesn't like this syntax and gives me an error:

Unknown attribute 'Published

I have no idea why. I'm using the Xcode 11 beta on macOS Catalina.

Any ideas?


回答1:


From the Xcode 11 Beta Release Notes (emphasis added):

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)


Update: This has been fixed with Xcode 11 beta 2. From the 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)




回答2:


Available in Xcode 11 beta 2, but have to import Combine



来源:https://stackoverflow.com/questions/56522258/ios-13-combine-framework-published-not-working-unknown-attribute-published

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!