do you know a good way to wait for replication to finish during an app shutdown in iOS?
I’m writing some Swift XCode Tests and it would be nice to see the produced test data replicated in the couchbase sever using the admin console.
Currently, the replication process has no time to do it’s job before the tests end.
The way I do it in .NET is by setting up a semaphore object that will be signaled during the changed event once the replication gets an idle (or stopped) status. Then the thread can block waiting for it. Another way is to simply sleep the thread for an arbitrary amount of time, but that is not as accurate or clean.
Just wait for the CBLReplication.status property to change to Idle or Stopped.
In a unit test, you’ll need to write a loop that spins the thread’s runloop so you can block until the status property changes. There are some examples of this in Unit-Tests/Replication_Tests.m in the iOS repository.