安装 pod 后无法访问 pod swift 文件

Not able to access pod swift file, after installing pod

我使用 raywenderlich tutroial 创建了一个 pod link,一切正常

  • 正在创建
  • 安装和
  • 也导入 pod
    但是当我尝试访问视图控制器时它说

    use of unresolved identifier 'file name'

    我试着用 cmd+click 跳转到文件的定义,它也将我导航到文件

    代码实现

    let bundle = Bundle(for: SDKSplashVC.self) // error here - Use of unresolved identifier 'SDKSplashVC'
    let storyboard = UIStoryboard(name: "SDKSplash", bundle: myBundle)
    let controller = storyboard.instantiateViewController(withIdentifier: "SDKSplashVC")
    self.present(controller, animated: true, completion: nil)
    

    我已经导入 pod,交叉检查托管方案和构建阶段,列出了我的自定义 pod,但仍然存在错误

    任何帮助都会很有帮助。 谢谢

  • 在教程中,作者使用 class PickFlavorViewController,它在 RWPickFlavor cocoa pod 中定义。

    let bundle = Bundle(for: PickFlavorViewController.self)
    

    你可以看一下这个pod中的所有文件here

    Docs 表示您可以使用 Bundleinit(for:) 初始值设定项来根据该框架中定义的 class 定位框架包。

    您收到错误是因为 SDKSplashVC 未定义。你需要这样写:

    import UIKit
    
    public class SDKSplashVC: UIViewController {}
    

    确保 class 定义为 public