saving files... a high level question

I have long since gone through converting my classes to support Codable, And I had an issue where I was using one of the powerful features of Objective programming, inheritance, to make an Array of a generic class, and populate it with subclasses of that class.

You can't just decode that array with the generic class type, you have to tear apart the array into separate arrays of the various subclass types, archive them and when you decode them, merge them back into that single array.

I get 'why' Codable forces you to name the type before you decode the object. security. makes sense. I'm 100% on board.

but I need to be able to duplicate the effect of having a Generically typed array, with subclasses in it, that can be saved to disk.

originally, I created an intermediate class that did tear apart the array, and then put it back together. The main issue with this is: it is impossible to make it portable. You'd have to write an entire class per array type. Further, it becomes unworkable when you cannot know the subclass type in advance, which I am working on right now. I'm adding plugin support. So the classes in the main bundle cannot know anything about the classes in the plugins.

I haven't found a way to store dynamic type in a variable, and I suspect that doing that would break the security anyway.

What I'm looking for... is a design pattern that incorporates all the flexibility of the Generically types array, but doesn't run afoul, Codable, while taking into account that I need to be able to add behavior and potentially variable to subclasses hosted in plugins, that will be required to be serialized in the Main bundle.