Strange behavior observed with the Sharing Core Data with CloudKit tutorial

Hi, I went over the tutorial for Sharing Core Data with CloudKit in SwiftUI. I then downloaded the materials for this tutorial and adapted them for my own sample app. For the longest time I was then struggling with a strange issue: the Sharing sheet would come up blank. I finally figured out what is the issue, and I was able to reproduce it with the original tutorial code.

Here’s what’s happening: if I comment out the content of the second Section in DestinationDetailView, starting with “if let share = share {”, then at the point where the sharing sheet is about to be presented (the first “.sheet” statement) the test for share fails (share is null). However, if I even just put back “let share = share” with no other code following it, everything works.

Can someone explain why this is happening?