This fixes 'NSInternalInconsistencyException's when presentViewController: and dismissViewController: are called, while a transition is already in progress. Transitions are queued for later execution.
dependencies: [
.package(url: "https://github.com/lovoo/LVModalQueue.git", .upToNextMajor(from: "0.3.0"))
]
pod 'LVModalQueue', :git => 'https://github.com/Lovoo/LVModalQueue'
Done! You don't have to import anything or change your existing code!
If a presentation or dismissal is currently in progress, when starting another one, a NSInternalInconsistencyException is thrown because a transition is already in progress.
Having a big app with a lot of external frameworks comes with a lot of challenges.
One of them is, that most of this frameworks tend to present their UIViewControllers on [UIApplication sharedApplication].keyWindow.rootViewController. Having truly interactive UIViewController transitions could also lead to multiple concurrent presentations as the user can start a transition, while an old one is still running.
LVModalQueue hooks into presentations and dismissals by swizzling into UIViewControllers presentViewController:animated:completion: and dismissViewControllerAnimated:completion: methods. If a transition is currently animating, it is queued for later execution when the transition is finished.
LVModalQueue was tested on iOS 7 and above in the LOVOO App with millions of users and reduced our crashes with concurrent transitions to zero.