Search code examples
macosswiftautostartosx-elcapitan

Sandboxed app autostart without ServiceManagement


I am creating a sandboxed app, and have gotten autostart working with the ServiceManagement framework. However, the ServiceManagement framework is being deprecated(since Xcode 7 beta 3) for Swift as the "ServiceManagement.framework module map" now includes the line requires !swift.

This produces the errors Could not build Objective-C module 'ServiceManagement' and Module 'ServiceManagement' is incompatible with the feature 'Swift' when I try to import ServiceManagement.

How to make autostart work with Swift and without the ServiceManagement framework?


Solution

  • The solution I found was to add a Bridging-Header file, and in that file import the framework. It would then be available to Swift as before.

    #import <ServiceManagement/SMLoginItem.h>