0

I am facing a serious issue. I have a framework named "abc.framework" and it contains a function in which you can pass a viewController object.

//this is the method in my framework 

func launchView(view:UIViewController){

}

//this is what needs to be written on App side

myFrameworkFile.launchView(view: self)

The above method is used to present the Framework's viewcontroller i.e abc.framework viewController on top of the the viewController object passed. The launch method contains the following code :

func launchView(view:UIViewController)
{


var rootController: UIViewController?

    rootController = view

    let storyboard = UIStoryboard(name: "abcFrameworkBundle.bundle/abcUIMain", bundle: nil)
    let VC1 = storyboard.instantiateViewController(withIdentifier: "selectedviewcontroller") as! SelectedViewController

    rootController?.present(VC1, animated: true, completion: nil)
}

From the above method the viewController the SelectedViewController viewDidLoad method is getting called however it is not getting presented and I am getting the below warning

Warning: Attempt to present on whose view is not in the window hierarchy!

Has anyone faced the same issue?

Omer Tekbiyik
  • 4,255
  • 1
  • 15
  • 27
Jeet Kapadia
  • 31
  • 1
  • 7
  • Will [this](https://stackoverflow.com/questions/11862883/attempt-to-present-uiviewcontroller-on-uiviewcontroller-whose-view-is-not-in-the) help you? Anyway, I would create static method inside your framework class which would return me instance of controller. So then you could just do in your project `let controller = SomeClass.instantiate(); present(controller, animated: true)` – Robert Dresler Feb 20 '19 at 20:32
  • where you are calling this method "launchView" ? – Abu Ul Hassan Feb 21 '19 at 07:44

1 Answers1

0

I guess you call this method myFrameworkFile.launchView(view: self) in viewDidLoad or earlier. Try to move it inside viewDidAppear