iOS 13 Public Beta 2-Combine.Future“ dyld:找不到符号”

时间:2019-07-04 17:34:44

标签: ios beta combine

在运行iOS 13 beta 2版本的iPad上启动我的应用程序时,我收到SIGABRT。此版本可以在模拟器上正常运行

dyld: Symbol not found: _$s7Combine6FutureCyxq_GAA9PublisherAAMc Expected in: /System/Library/Frameworks/Combine.framework/Combine

我以为这可能是链接问题,但是Combine并未出现在可链接的库列表中。

有人在工作吗?还是我沉没到下一个测试版?


这是我的代码段:

class ViewController: UIViewController {

    var future: AnyPublisher<String, Error>?

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        future = ViewController.makeNumberString(50)
        future?.sink { result in
            print("FUTURE DONE: \(result)")
        }
    }

    static func makeNumberString(_ number: Int) -> AnyPublisher<String, Error> {
        return Combine.Future<Int, Error> { complete in
            DispatchQueue.global(qos: .userInitiated).async {
                complete(.success(number))
            }
        }
        .map { number in
            return "\(number)"
        }
        .eraseToAnyPublisher()
    }
}

2 个答案:

答案 0 :(得分:1)

您的Xcode Beta和您的iPadOS / iOS Beta版本应该匹配。否则,合并可能无法链接到您的应用程序。

答案 1 :(得分:0)

当我在iPad Pro w 13.0(17A5522f)上运行的Xcode 11.0 beta 3(11M362v)中测试以下内容(以及您的代码段)时,效果很好。

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        print("viewDidLoad")

        _ = bar().sink { value in
            print("sink", value)
        }
    }

    // some old asynchronous method

    func foo(completion: @escaping (Bool) -> Void) {
        DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
            completion(true)
        }
    }

    // `Future` promise for that old async method

    func bar() -> AnyPublisher<Bool, Never> {
        Future { promise in
            self.foo { value in
                promise(.success(value))
            }
        }
        .eraseToAnyPublisher()
    }
}