Swift 3 - custom segue crashed with UIStoryboardSegueTemplate.m:85
<p>According to this <a href="https://www.appcoda.com/custom-segue-animations/" rel="nofollow noreferrer">link</a>, I am trying to make my own custom segue.</p>

<p>In the initial view controller (titled: <code>First</code>), pressing <code>2</code> (<code>UIButton</code>) to segue to <code>Second</code>. </p>

<p>But the app always crashes at <code>performSegue(withIdentifier: "customSegue", sender: self)</code> with error: <code>*** Assertion failure in -[UIStoryboardSegueTemplate segueWithDestinationViewController:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3599.6/UIStoryboardSegueTemplate.m:85</code></p>

<p>Here is the main storyboard:</p>

<p><a href="https://i.stack.imgur.com/VO8UH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VO8UH.png" alt="enter image description here"></a></p>

<p>Crash:</p>

<p><a href="https://i.stack.imgur.com/eHWvQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eHWvQ.jpg" alt="enter image description here"></a></p>

<p><code>CustomSegue</code></p>

<pre><code>import UIKit

class CustomSegue: UIStoryboardSegue {

    override func perform() {
        let sourceView = source.view!
        let destView = destination.view!

        let screenWidth = UIScreen.main.bounds.size.width
        let screenHeight = UIScreen.main.bounds.size.height

        destView.frame = CGRect(x: 0, y: screenHeight, width: screenWidth, height: screenHeight)

        let window = UIApplication.shared.keyWindow
        window?.insertSubview(destView, aboveSubview: sourceView)

        UIView.animate(withDuration: 0.4, animations: { 
            sourceView.frame = sourceView.frame.offsetBy(dx: 0.0, dy: -screenHeight)
            destView.frame = destView.frame.offsetBy(dx: 0.0, dy: -screenHeight)
            }) { [weak self] (finished) in
                guard let strongSelf = self else { return }

                strongSelf.source.present(strongSelf.destination, animated: false, completion: nil)
        }

    }
}
</code></pre>

<p><code>Second</code> is just an empty View Controller:</p>

<pre><code>import UIKit

class Second: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

}
</code></pre>

<p>I compare the setup in my project with the downloaded sample but cannot find the difference. </p>

<p>How should I fix this crash?</p>