Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine in Playgrounds

I'm inspecting Combine, a new framework by Apple. I created a playground, ran it in macOS Mojave 10.14.5 and Xcode 11.0 beta (11M336w).

Here is my code:

import Combine

struct Article: Identifiable {

    var id: Int
    var title: String
}

final class Data: BindableObject {

    let didChange = PassthroughSubject<Data, Never>()

    var showFavouriteOnly = false {
        didSet {
            didChange.send(self)
        }
    }
    var articles: [Article] = [.init(id: 1, title: "WWDC 2018"),
                               .init(id: 2, title: "WWDC 2019")] {
        didSet {
            didChange.send(self)
        }
    }
}

But it fails with log:

error: Couldn't lookup symbols: Combine.PassthroughSubject.send(A) -> ()

What am I doing wrong?

like image 995
Artem Novichkov Avatar asked Jun 05 '19 14:06

Artem Novichkov


1 Answers

If you created an iOS playground, then Combine should work even if you’re running Xcode 11 or later on macOS 10.14. If you created a macOS playground, Combine will only work if you are running Xcode 11 or later on macOS 10.15 (Catalina) or later.

If you created an iOS playground, then it’s entirely possible that you have found a bug in Combine (or in the Swift compiler). You can report it at Apple’s feedback site if you like.

like image 123
rob mayoff Avatar answered Oct 07 '22 17:10

rob mayoff