Speculation on XPC for iOS

I've read several articles lately from some talented iOS developers talking about the possibility that XPC services may make their way to iOS in a future version.  It's a really fascinating possibility and I hope it comes to pass.  XPC is a method for processes to communicate with each other which is tied in with Grand Central Dispatch.  Introduced in OS X Lion and refined in Mountain Lion, XPC is already included as a private framework in iOS 6, so indications are good that it could make it's way into iOS 7.

One way that XPC could be used is to create Remote View Controllers.  Ole Begemann has a great overview of this on his blog, oleb.net, including some research into current iOS frameworks which are using remote view controllers.  Essentially an app creates another executable which can vend out a remote view controller to other apps.  Now there's a lot that goes into how the app determines which of these remote view controllers may be useful to it (i.e. if they can consume the type of content the app wants to share) but the gist of it is that the currently running app opens up a portal to a small piece of another app and all of the touch events and user input gets forwarded to that app which is running in a separate process.  That lets the remote view controller take care of all the nitty gritty details of posting to twitter without the currently running app having to worry about it.

I wanted to speculate a bit on what this could mean to iOS.  iOS has been a sandboxed platform since day 1.  We didn't get multitasking until iOS 4, and even now it's not exactly open season on parallel tasks and communication between apps.  The only way that apps can communicate with each other now is through URL schemes.  There's been some creativity around URL schemes, such as how Facebook has a global login system between all of it's applications (and apps that want to use Facebook), but it's still a cumbersome system.  It requires every app to know about every other app, including which URL schemes it responds to.  That's not a scalable system at all which is why we need something better.

The obvious value that XPC and Remote View Controllers could bring is sharing.  Apps like Instapaper or Instagram could publish sharing activities and view controllers that allow any app to post a link to Instapaper or a picture to Instagram.  There's definitely a need for this type of service so I hope it's something we see soon.  If you're worried about having too many sharing options, I could see a notification center-style interface for managing these options.  Since apps would have to publish what they can handle in terms of content, it should be straightforward to provide a static interface for managing that in Settings.

Some less obvious use-cases for XPC and Remote View Controllers are global authentication schemes and remote detail views.  Authentication with various services is a very common problem on iOS.  Facebook and Twitter used to be the most common that required some form of authentication, which would have to be baked into an app in the form of an SDK or OAuth implementation.  Now, thanks to integration in iOS, this is no longer a major issue.  But there's still plenty of other services (Dropbox for example) that plenty of apps need to authenticate to.  Wouldn't it be nice if the Dropbox app could vend an authentication view controller to any app that needed to login to Dropbox?  It would definitely be a better experience than using URL schemes to go back and forth to the Dropbox app, and it would also keep the responsibility of safely authenticating in Dropbox's court, where it belongs. 

We know that Apple's own App Store modal view controllers (from Mail and Safari) are using XPC under the hood.  There's plenty of potential here for other apps to offer similar forms of detail views.  Shopping is certainly a great use case for this as well with things like Amazon or Google Shopping being obvious possibilities.

Another place that XPC could kickstart a revolution on iOS is the Notification Center.  When Notification Center debuted in iOS 5 we were greeted with widgets for Weather and Stocks.  What's been obvious since then is that those widgets are not system-wide, but rather tied to the existence of the corresponding Weather and Stocks apps.  That's why they are only on the iPhone, not the iPad, because those apps don't exist there.  This could be another use case for XPC, where apps could be able to vend remote views which exist in the Notification Center as small widgets.  There's some great user experience gains to be had by widgets, such as quick access to data (Weather, Scores, etc.), basic controls for things like timer apps, or quickly launching apps similar to David Barnard's original vision for Launch Center.  Shoot, I know I wouldn't mind having a flashlight widget in my Notification Center.

Here's a last stretch speculation for XPC.  What if Apple converted UIWebView to run in a separate process and use XPC?  There's long been a disadvantage for hybrid/web apps that run inside of a wrapped web view because they don't have access to the same Nitro JavaScript engine that mobile safari uses.  The reasoning I've heard for that is that it isn't secure enough when it's in the same process as the app.  Would putting the web view in another process and using XPC for it to communicate with the host-app be enough to secure it such that any app could have access to Nitro?  That would certainly improve Apple's status as a leading platform for mobile web developers.  This is definitely a stretch, but it's exciting to think about.

There's just so much potential with XPC that I have to believe Apple is working on bringing this technology to iOS.  Hopefully it will make it for iOS 7, but even if it's still a few versions out I am still excited just thinking of the possibilities that it could bring to the platform.

Definitely check out Ole Begemann's series below, as well as Kyle Baxter's speculation and Federico Viticci's interview with Loren Brichter.  If you think any of this sounds cool too, definitely file an enhancement request: