My goal is to create a text view where two users can type at the same time in a text document (for example UITextView). I am currently using firebase as my database.
One way one could implement this is to update a document all the time from firebase with listeners attached to it that update the text. This approach isn't very practical and can cause confusion right away when one internet connection is poor.
Is it possible to create a shared text document in Swift where two users can type? And is there a more convenient approach to it than mine?
What you're describing is essentially what Firepad does on the web.
You could consider using its source code as the basis for your solution, paying special attention to the operation transform implementation in there, which is what makes its multi-user editing of a single document possible.