Sharing data between iOS apps and app extensions

Since iOS app extensions run as part of a host application rather than as part of their containing app (i.e. your app’s extensions run in somebody else’s app), data sharing isn’t automatic. Finding standard locations like the documents directory doesn’t work for shared data. In this post I’ll go through the details of how to make it all work.
Along the way I’ll get into how to set up real-time messaging between apps and their extensions.