Xcode 11.4 beta crash on @Published property subscription. What's going on?
Asked Answered
S

1

11

I do not know why but my code crashes on this $searchTerm publisher. I have many such publishers in my code and everything else works ok. It only does not work in this new Xcode version and works in previous version. If I commented this line and replace it with _searchTerm.projectedValue it starts working as usuall!

 _searchTerm.projectedValue
    //$searchTerm
        .debounce(for: .milliseconds(350), scheduler: DispatchQueue.global())
        .flatMap { term in
            self.search(by: term)
        }
        .print("searching")
        .receive(on: DispatchQueue.main)
        .assign(to: \.results, on: self)
        .store(in: &disposables)

I have error

Fatal error: Call of deleted method

Shushan answered 10/2, 2020 at 17:42 Comment(5)
Please file a bug report with Apple if you haven't done so already. Thanks!Caucus
same here! did you file a bug report or rdar. It crashes only with Xcode 11.4Hermit
Thanks for the tip on getting around this, works like a charm! Happens on XCode 11.4.1 as wellPlanoconvex
Many facing this since Xcode 11.4. I filed a bugreport. But not (surprise surprise...) no feedback yetHermit
See also #60464726Caucus
C
1

If searchTerm is something declared in your class or its superclass then mark it as final. In my experience this fixes this issues all the time.


My theory is that Swift can't figure out which field from lookup tables is $searchTerm is referring, hence the crash. Where as, marking it as final will make it dispatch statically. I'm not sure whether this is actually true or not, if anyone has more knowledge on subject please make a comment and I'll update my answer.

Commonalty answered 16/5, 2020 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.