Setting `navigationItem.standardAppearance` overrides backButtonImage setting

Hello everybody. I need your help with configuring navigationItem properly.

I want to use its appearance properties to configure how the navigation bar looks on per-screen basis without interacting with UINavigationBar directly (the API has been implemented for this specific use case, right?)

What I'm confused about is that setting any appearance property resets back button image to the default chevron.

What I do now:

Inside my app delegate

let navigationBarAppearance = UINavigationBar.appearance()

navigationBarAppearance.backIndicatorImage = UIImage()
  navigationBarAppearance.backIndicatorTransitionMaskImage = UIImage()

I do this to hide the default chevron to customize back button appearance on per-view-controller basis

Then in my presenting view controller:

  override func viewDidLoad() {
    super.viewDidLoad()
    
    navigationItem.title = "Root"
    
    navigationItem.backBarButtonItem = UIBarButtonItem(
      title: nil,
      image: nil,
      primaryAction: UIAction(
        title: "",
        image: UIImage(systemName: "square.and.arrow.up"),
        identifier: nil,
        discoverabilityTitle: nil,
        attributes: [],
        state: .on,
        handler: { [weak self] _ in
          self?.navigationController?.popViewController(animated: true)
        }
      ),
      menu: nil
    )
    
    let appearance = UINavigationBarAppearance()
    appearance.configureWithTransparentBackground()
    appearance.backgroundColor = UIColor.red
    appearance.titleTextAttributes = [
      .foregroundColor: UIColor.purple
    ]
    appearance.largeTitleTextAttributes = [
      .foregroundColor: UIColor.purple
    ]
    
    navigationItem.standardAppearance = appearance
    navigationItem.compactAppearance = appearance
    navigationItem.scrollEdgeAppearance = appearance
    navigationItem.compactScrollEdgeAppearance = appearance
  }

The colors are set up as expected, however the default chevron image appears on the next view controller next to square.and.arrow.up. If I don't touch navigation item appearance properties - only square.and.arrow.up is displayed, as I want, but obviously I loose all the customization.

Can anyone please explain how to set things up properly? Thanks!

Setting `navigationItem.standardAppearance` overrides backButtonImage setting
 
 
Q