Deinitializer won't get called

I'm presenting a view controller inside a UIAction handler from the new UIButton init configuration API. But when I do it, its deinit won't get called.

I'm thinking there's some sort of retain cycle? I've tried capturing [weak self] inside the closure with no success. Using the addTarget method instead, the deinit gets called as expected.

What am I doing wrong?

let testVC = TestViewController()
lazy var testButton: UIButton = {        
    var configuration = UIButton.Configuration.filled()
    //button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
    let button = UIButton(configuration: configuration, primaryAction: UIAction(handler: { action in
        self.present(testVC, animated: true, completion: nil)            
    }))
    return button
}() 

There's probably a retain cycle capturing either self or testVC, the code sample is missing the context to say for sure. Is testButton added as a subview to the TestViewController's view? That will cause a cycle.

Deinitializer won't get called
 
 
Q