Search code examples
iosswiftcocoapodspodspec

Not able to access pod swift file, after installing pod


I have created a pod using the raywenderlich tutroial link, everything works fine

  • creating
  • installing and
  • importing the pod too
    but when I am trying to access the view controller its says

    use of unresolved identifier 'file name'

    I tried cmd+click to jump to defination of the file and it navigating me to the file also

    code implemented

    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)
    

    I have imported the pod, crossed check in managed scheme and build phases, my custom pod is listed their but still error persist

    Any help would be really helpful. Thank you


  • Solution

  • In the tutorial author is using class PickFlavorViewController which is defined in RWPickFlavor cocoa pod.

    let bundle = Bundle(for: PickFlavorViewController.self)
    

    You can take a look and see all the files in this pod here.

    Docs say that you can use the init(for:) initializer of Bundle to locate the framework bundle based on a class defined in that framework.

    You are getting the error because SDKSplashVC is not defined. You need to write something like this:

    import UIKit
    
    public class SDKSplashVC: UIViewController {}
    

    Make sure the class is defined as public.