Xcode Project Setup to Build, Embed, Codesign, Notarize, and Use the Sparkle XPC Services
In the previous post, I talked about how to download the "modern" Sparkle updater branch called ui-separation-and-xpc
that allows you to update sandboxed apps and migrate your code to use the new types. This time, we're going to use the actual XPC services that do the grunt work.
How Do You Activate Sparkle's XPC Services?
The Sparkle XPC fork is even better than I would've imagined! As I mentioned in the previous post about Sparkle's XPC branch, you can switch to the new framework version and the new types without having to change much else. The new API is very similar to the old one. If you switch to the work-in-progress ui-separation-and-xpc
branch, then you can continue to use CocoaPods or Carthage if all you want is the new API.
Use Shared NSUserDefaults for XPC and Interface Builder Nibs
The default Interface Builder approach of using a "Shared User Defaults Controller" object breaks down if your app preferences are not stored in the standard place. Both my apps The Archive and the Word Counter for Mac are comprised of multiple executable applications. For The Archive, it's the main app and the Quick Entry popup window. They share some settings, like which theme and font size is used. To share these settings, I rely on NSUserDefault
(or just UserDefaults
in Swift now). I cannot use the UserDefaults.standard
, though, because that is tied to the currently running app's bundle ID. In the case of the main app, it's the ID of the main app; but for the Quick Entry helper – or any helper app –, it's the helper's bundle ID. This way, the defaults dictionaries are not shared.
Getting XPC to a Helper App Working with Sandboxing Enabled
Here's how I fixed the inter-process communication sample app called AppSandboxLoginItemXPCDemo by Apple to make it work. When I tried it out at first, sandboxing ruined the day. You have to change a few things in order to make it work.