Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

swift

combine

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?

like image 576
Quantm Avatar asked Jun 10 '19 07:06

Quantm


2 Answers

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)

like image 200
Martin R Avatar answered Oct 23 '22 15:10

Martin R


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

like image 1
user3513493 Avatar answered Oct 23 '22 15:10

user3513493