Use C-function in swift

It’s already fine like this but yes dynamically would be better!

That's the whole new game...

  • InlineArray is then out of question
  • Array won't work at all as C can't deal with it whatsoever
  • perhaps std array + std string + C++ could work (never tried from Swift)
  • "C is King" approach (where C would do all allocations / reallocations and Swift will use that).
  • "Swift is King" approach (the same but in reverse where C will treat what Swift provided as Opaque data structures, in this case what Swift provides will have to be reference types.
  • Objective-C wrapper (with some compromises down the road, like using reference types instead of value types).
  • Something else (I wonder what did @Sajjon have in mind).

As an example of "C is King" approach you may use a differently shaped C-API like so or similar:

// add nullable or nonnull annotations below:
typedef struct CItems;
CItems* createItems(void);
void destroyItems(CItems*);
int numberOfItems(CItems*);
const char* itemAtIndex(CItems*, int);
// append / insert / remove if needed

This will be easy to call from Swift and this storage managed by C will be treated as opaque in Swift.