7

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?

Artem Novichkov
  • 2,356
  • 2
  • 24
  • 34

2 Answers2

2

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.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
1

The first version of Xcode 11 beta does not have Combine working, it has been stated in the release note.

You should download the second Xcode 11 beta (11M337n)

hybridcattt
  • 3,001
  • 20
  • 37
L N
  • 2,856
  • 4
  • 20
  • 30
  • +1: Also, certain beta versions seem to have breaking issues as well – e.g. beta 4 likes to crash with Combine @Published properties... your best bet is to ensure you're always on the latest beta. – JRG-Developer Aug 04 '19 at 06:45