创建依赖于RxSwift的自己的库仍然需要导入RxSwift?

问题描述 投票:3回答:1

我尝试使用RxSwift作为依赖项创建一个名为MyLib的库,它使用cocoapod命令pod lib create。但是,以下代码不起作用。

import UIKit
import MyLib

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    // compile error: Use of unresolved identifier 'Observable'
    Observable.just("")
  }

}

它只在我添加import RxSwift后才有效

我想只导入MyLib,有任何想法吗?

谢谢!

swift cocoapods rx-swift
1个回答
4
投票

Observable不是你的类,所以关于RxSwift开发人员,建议使用这个导入。

但是如果你真的想要在你的库中尝试使用qalxswpoi的typealias吗?

例如:Observable

© www.soinside.com 2019 - 2024. All rights reserved.