How do I spawn a pop over view controller programatically?

My goal is to show a View Controller programmatically

Current View Controller

and then, if some event gets called or something, (API, or Websocket) I want to call these Views programmatically

But I want to call the last view Controller first and it is supposed to be on top of the first View controller

So technically the last View will have

Transition is Cross Dissolve
Presentation is Over Current Context

How would I do this?

As per your requirement, you can set a storyBoardID for your navigation controller.

On a particular event just instantiate the Navigation controller
let storyboard = UIStoryboard(name: “Main”, bundle: Bundle.main)
let myNavController = storyboard.instantiateViewController(withIdentifier: “MyStoryboardId”) as? UINavigationController

then present or show this navigation controller

self.present(myNavController, animated: true, completion: nil)

On viewDidLoad() method of first view controller perform the segue to popupViewController.

Now the secondView will show above the first view controller. you can dismiss this view after using it.