swift - 使用组合时出现运行时错误 : dyld: Symbol not found: _$s7Combine9PublishedV9PublisherCyx_GAadAMc

标签 swift swiftui combine

我正在使用 Xcode 11 Beta 5 (11M382q) 和装有 iOS 13 beta 6 的 iphone x,并且在尝试使用合并时遇到此运行时错误:

dyld: Symbol not found: _$s7Combine9PublishedV9PublisherCyx_GAadAMc

我有一个核心类,它是一个ObservableObject

import SwiftUI
import Combine

open class Core: ObservableObject {
    @Published public var userId = ""

    public var isUserValid: AnyPublisher<Bool, Never> {
    return $userId.debounce(for: 0.5, scheduler: RunLoop.main).removeDuplicates().map { (user: String) in
      return user.isEmpty
    }.eraseToAnyPublisher()
  }
}

还有一个简单的 View

import SwiftUI
import Combine

struct LoginView: View {
    @EnvironmentObject var core: Core
    @State var isLoading: Bool = false
    @State var submitButtonEnabled: Bool = false

    var body: some View {
        VStack {
            VStack(alignment: .center) {
                Image("logo")
                    .frame(minWidth: Constants.logoWidth, minHeight: Constants.logoHeight, alignment: .center)
                    .padding(.top, Constants.logoTopPadding)
                    .animation(.default)
                    .scaledToFit()
             }
        }

        CircularButton(isLoading: $isLoading, image: Constants.submitButtonArrowImageName) {
            // Button Action
        }
        .padding(.top, Constants.submitButtonTopPadding)
        .disabled($submitButtonEnabled.value)
        .onReceive(self.core.isUserValid) { value in
          self.submitButtonEnabled = value
        }
    }
}

我的代码有什么问题吗?我只想要一个使用响应式(Reactive)编程来禁用或启用按钮的 MVVM 架构。

最佳答案

我下载了 Xcode 11 beta 6、iOS 13 beta 7,现在运行良好。这是之前测试版的一个错误。

关于swift - 使用组合时出现运行时错误 : dyld: Symbol not found: _$s7Combine9PublishedV9PublisherCyx_GAadAMc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57513437/

相关文章:

ios - Swift:删除 iOS 操作扩展中的照片

ios - SwiftUI 列表数据的可识别协议(protocol)扩展

ios - Swift 组合 : Run a list of publishers one after the other, 并发布第一个非零元素

swift - 在组合 swift 中没有调用 sink()

ios - 当ObservedObject更改时,在SwiftUI View 中不会调用onReceive

ios - 从代码访问 TableView 标题

ios - 更新 CoreData 中的项目不会刷新 tableView

ios - 使用 6 位数字(而不是 4 位)同步短信验证

带有 AnyView 的 SwiftUI 对象数组

ios - SwiftUI 中的 "Task finished with error [-999]"