I\'d like to compact a Realm instance on iOS periodically to recover space. I think the process is to copy the db to a temporary location, then copy it back and use the new defa
Well.. it appears as though this issue is mostly obsolete. Realm added an automatic compact feature last fall. Realm Docs / compacting-realms. I think the only reason to do it as described by @marius is if you need to control the user experience and compact in the background.
See this question for more: How to correctly use shouldCompactOnLaunch in RealmSwift