Mac Catalyst: Presenting view controller <UIAlertController:> from detached view controller <MyViewController:> is not supported, and may result in incorrect safe area insets and a corrupt root presentation on Sonoma

Okay so I'm getting this log every time I present a UIAlertController:

Mac Catalyst: Presenting view controller <UIAlertController: 0x10f027000> from detached view controller <MyViewController: 0x10d104080> is not supported, and may result in incorrect safe area insets and a corrupt root presentation. Make sure <MyViewController: 0x10d104080> is in the view controller hierarchy before presenting from it. Will become a hard exception in a future release.

A few points:

  1. MyViewController is not detached and the presentation shows just fine.
  2. I specifically check for this before presenting the alert controller like so:
  BOOL okayToPresentError = (self.isViewLoaded
                             && self.view.window != nil);

if (okayToPresentError)
{
    [self presentErrorInAlertController:error];
}
else
{
     //Wait until view did appear.
     self.errorToPresentInViewDidAppear = error;
}

It spews out every time an error is fed back to my app and I present the alert controller (I can turn off the network connection and I show an alert controller with a "retry" button in it which will loop the error back so I can replay the error alert presentation over and over again) .

Every time the alert controller is presented, I get this spewing in the console. Please don't start throwing hard exceptions because the check is faulty.

I am having this same issue. If anyone has a fix please post it here.

I was having the same issue. I have been able to get rid of it by calling "addChildViewController" and "didMoveToParentViewController".

Mac Catalyst: Presenting view controller &lt;UIAlertController:&gt; from detached view controller &lt;MyViewController:&gt; is not supported, and may result in incorrect safe area insets and a corrupt root presentation on Sonoma
 
 
Q