How can I apply safeAreaLayouts to multiple views?

When my app starts up I have my ViewController, which automatically creates my MainScreen (also a view controller). Right after

self.addChild(mainController)

I call a function which sets my constraints

    func setConstraints (vc: UIViewController) {
        vc.view.translatesAutoresizingMaskIntoConstraints = false

        var constraints = [NSLayoutConstraint]()
        constraints.append(vc.view.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor))
                 constraints.append(vc.view.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor))
                 constraints.append(vc.view.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor))
                 constraints.append(vc.view.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor))
         NSLayoutConstraint.activate(constraints)
    }

All is fine up to this point, the MainScreen is bound by the top and bottom safe areas.

At some point from MainScreen I create another UIViewController.

        countController.modalPresentationStyle = .fullScreen
        self.present(countController, animated: true, completion: {})

Yet, no matter how hard I try to apply the constraints to the new controller, I crash with the following msg:

Unable to activate constraint with anchors <NSLayoutXAxisAnchor....because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal."

Am too new to figure out where my error is.