Here’s an earlier discussion with a few more links:
https://forums.swift.org/t/how-can-i-encode-a-struct-to-data-binary