Instantiated optional variable shows as nil in Xcode debugger

The cause of the bug is not that var start_time: Date? is present or absent, but that Date is a Swift Foundation overlay. If you remove the Codable conformance and make start_time an NSDate?, everything is fine. So clearly LLDB gets confused by Swift overlay types like Date?.

In this linked question, we see the same issue with URL?. If we change it to NSURL? everything is fine.

I'm not saying that that's a viable workaround! You want and need to use Swift types. I'm just saying that this is what is messing up LLDB. You can include that info when you report the bug.

This bug is slated to be fixed in Xcode 12.5.


It appears I've found a bug in Xcode 11. It's easily reproducible as outlined in the UPDATE above. I've filed the bug with Apple.

I'm still looking for a workaround now, since I use quite a few structs containing Date variables. If anybody can find one, please comment below.