Xcode 14: [Assert] UINavigationBar decoded as unlocked for UINavigationController

In Xcode 14 RC, I'm seeing this in the Console:

[Assert] UINavigationBar decoded as unlocked for UINavigationController, or navigationBar delegate set up incorrectly. Inconsistent configuration may cause problems. navigationController=<MasterNavigationController: 0x135016200>, navigationBar=<UINavigationBar: 0x134f0aec0; frame = (0 20; 0 50); opaque = NO; autoresize = W; layer = <CALayer: 0x600000380be0>> delegate=0x135016200

The above message displays exactly four times immediately at app launch (top of the console) then does not repeat.

MasterNavigationController is the internal class for the app's navigation controller. It is in a Storyboard, with very minimal ObjC code. I am not setting any specific size for the nav bar.

I don't remember seeing this in earlier builds of Xcode, but I can't swear to it that this is new. No assertion actually fires.

Post not yet marked as solved Up vote post of mitchcohen Down vote post of mitchcohen
27k views
  • I also find that promblem.

    **How I fix it. **

    If you use storyboards. Take the arrow(Attribute inspector-> is initial view controller) from Navigation View Controller in storyboard and put it in your next View Controller.

    Simplify change initial view controller in storyboard

  • TimMan, this fixes the logs, but disables the nav controller.

Add a Comment

Replies

I solved this problem by

//initiating my Home ViewController from custom Splash Screen let vc:HomeViewController = Storyboard.Home.initiate() let nav = UINavigationController(rootViewController: vc) window.rootViewController = nav UIView.transition(with: window, duration: 0.6, options: .transitionCrossDissolve, animations: {}, completion: { completed in if completed { window.makeKeyAndVisible() } })

a Simulator with a lower ios version did it for me. Iphone X with ios 13

this bug is egg pain for me.

Dear all, I'm using latest XCode Version 14.2 (14C18), and yes still have this problem. Even did a simple project with Embed-in Navigation Controller will give me the same message:

2023-01-16 10:37:10.872324+0800 test7[3313:4969594] [Assert] UINavigationBar decoded as unlocked for UINavigationController, or navigationBar delegate set up incorrectly. Inconsistent configuration may cause problems. navigationController=<UINavigationController: 0x7fa546808200>, navigationBar=<UINavigationBar: 0x7fa543f05290; frame = (0 59; 0 50); opaque = NO; autoresize = W; layer = <CALayer: 0x600000577ea0>> delegate=0x7fa546808200

Tried few suggested solution but still have this problem - The Apps is working fine (tested on simulator and on devices) just the message will appear one time in the console when run it.

anyone solve this ? or is it a confirmed bug on Xcode ?

Thank you.

HOW I SOLVED FOR ME, hope this helps:

**Why it was happening: ** My app was going from a UIView that was inside a nav controller to a modal with no nav bar to a uiview again: 1.NAV BAR UIVIEW ---> 2. NO NAV BAR MODAL VIEW -> 3. UI VIEW For some reason the final destination screen was treated like it was outside of the navigation controller group, because the previous screen was a modal that hid the nav bar. There are loads of overcomplicated-solutions out there about that part but I found the below combination fixed all issues. In brief, it's got to do with segues/presenting screen AND the "Presentation" setting in attributes in storyboard in the screen which followed the modal. HARD TO EXPLAIN BUT CHECK THE SOLUTION IN DIFFERENT COMBINATIONS TO SEE IF IT WORKS FOR YOU - Note my error message contained [Presentation] at the beginning which made me realise what might be happening, your error message may have something different but check for that word in the storyboard right hand pane.

**How I fixed it: ** If your app is using a navigation controller and you have a modal view (or any other view) that hides the nav bar:

A. Put this in your modal view :

   override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationController?.setNavigationBarHidden(true, animated: animated)
  }

  override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    navigationController?.setNavigationBarHidden(false, animated: animated)
  }

B. then put this in the view that comes directly after the modal view i.e. the one you present or segue to afterwards

   override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationController?.setNavigationBarHidden(false, animated: animated)
  }

C. then, in storyboard, select the view that comes after the modal view and in the right hand pane, under attributes inspector --> view controller section: presentation -> select "Full Screen"

For me updating to xcode 14.3 solved the problem

I'm not 100% sure that my issue was related to the assert warning. However I can see a number of similarities in what some people have reported here.

For me, this issues caused a done button on my navigation bar to freeze. My app while running in debug in the simulator with Xcode 14.3 / iOS 16.4 worked fine. If I kill my app and run it without debug on the simulator the freeze would occur.

Also occurs on an real device.

This is what caused my issue..

    [[UINavigationBar appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
            [UIFont fontWithName: APP_FONT size: [SharedCommon setAppFontSizeNavigationTitle]],
            NSFontAttributeName, nil]];

I fixed it with this...

    if (@available(iOS 15.0, *))
    {
        UIBarButtonItemAppearance *bbItemAppearance = [[UIBarButtonItemAppearance alloc] init];
        bbItemAppearance.normal.titleTextAttributes =
        [NSDictionary dictionaryWithObjectsAndKeys:
         [UIFont fontWithName: APP_FONT
                         size: [SharedCommon setAppFontSizeNavigationButton]],
         NSFontAttributeName, nil];

        UINavigationBarAppearance *navBarAppearance = [[UINavigationBarAppearance alloc] init];
        &#x2F;&#x2F; .... other appear here
 
        navBarAppearance.buttonAppearance = bbItemAppearance;

        [UINavigationBar appearance].standardAppearance = navBarAppearance;
        [UINavigationBar appearance].scrollEdgeAppearance = navBarAppearance;
    }
    else
    {
        [[UIBarButtonItem appearance] setTitleTextAttributes:
         [NSDictionary dictionaryWithObjectsAndKeys:
                [UIFont fontWithName: APP_FONT
                                size: [SharedCommon setAppFontSizeNavigationButton]],
                NSFontAttributeName, nil] forState: UIControlStateNormal];
    }

Hope this helps someone...

Jules.

I just deleted the app and relaunched. It worked for me

I think I had the same issue before. Recently, when I updated my Xcode to 14.3, my iOS app crashed right at the launch time.

I posted my question to StackOverflow. With some developer hints and advice, I finally got the issue found and the problem resolved.

See my post question at SO:

iOS app crashes built by Xcode 14.3: Cannot manually set the delegate on a UINavigationBar