Ultimately all data transmission is happening in bytes.
You need to think about:
- What operations do want to do on your data when it is loaded in program memory.
- How to model in-memory representation of your data.
- How to structure serialized representation.
- How to convert between in-memory and serialized representations.
Looks like you want your serialized representation to be Swift source code. Swift source code can contain a lot things, including imports of frameworks, declarations of custom operators, conditional compilation directives, and arbitrary executable code which pose security risks. Is this really the best representation of your data?