How to handle multiple View Models with Data Binding in iOS runtime?

Hi everyone 👋


I’m experimenting with Rive Data Binding on the iOS runtime and I’m a bit unsure about the intended way to work with multiple View Models.


In my .riv file, I have several View Models:

  • Some control specific visual components

  • Some are referenced by the state machine

On iOS, I create instances for each View Model and try to bind them to the same artboard / state machine. However, it looks like binding a new ViewModelInstance replaces the previous one, so only the last bound instance actually drives the animation.


Simplified example:
```
let letterInstance = riveFile

.viewModelNamed("View Model Letter")!

.createDefaultInstance()!

let giftInstance = riveFile

.viewModelNamed("Gift Model")!

.createDefaultInstance()!

let envelopeInstance = riveFile

.viewModelNamed("Envelope Model")!

.createDefaultInstance()!

stateMachine.bind(viewModelInstance: letterInstance)

stateMachine.bind(viewModelInstance: giftInstance)

stateMachine.bind(viewModelInstance: envelopeInstance)
```
After this, I can only control one View Model’s data.


So I’m wondering:

  • Is the iOS runtime designed so that only one ViewModelInstance can be bound to an artboard/state machine at a time?

  • If an animation needs data from multiple logical View Models, is the recommended approach to:


    • create a single “root” View Model and nest other View Models inside it in the editor?

    • or is there another intended pattern?


Would love to hear how others structure this, especially on iOS. Thanks in advance!