Can we use the DiskArbitration framework inside of an XPC service ?

We are updating our application to xcode 8 with SDK 10.12 moving our services from unix daemons to xpc services.

The issue that we have now is that previousl both of our daemons included DiskArbitration framework to list presence of mounted volumes.

After we moved our code to XPC service we are no longer seeing any diskarbitration notifications in the xpc service.

On a different note can we just start the xpcservice in xcode without the whole app for debugging ?

Code and framework linking is the same as we had in previous project. xcode 8 and sdk 10.10



The following code is included in the init of the class, and we dont get any callbacks


diskArbSession = DASessionCreate(kCFAllocatorDefault);

DARegisterDiskAppearedCallback (diskArbSession,

NULL,

diskAppearedCallback,

(__bridge void *)(self));

DARegisterDiskDisappearedCallback (diskArbSession,

NULL,

diskDisappearedCallback,

(__bridge void *)(self));

DARegisterDiskDescriptionChangedCallback (diskArbSession,

NULL,

NULL,

diskDescriptionChangedCallback,

(__bridge void *)(self));

DASessionScheduleWithRunLoop (diskArbSession,

[[NSRunLoop mainRunLoop] getCFRunLoop],

kCFRunLoopDefaultMode);

Accepted Reply

I don't know the answer to your question, but it occurs to me that there might not actually be a run loop in the XPC service. Could you try scheduling the DASession on a dispatch queue instead?


Generally, though, this seems like an issue that it'd be worthwhile to spend a TSI (tech support incident) on. That way you'd have an Apple engineer advising you on what was technically possible. Given the inadequancy of the DiskArbitration documentation, it might be quicker overall to take that approach.

Replies

I don't know the answer to your question, but it occurs to me that there might not actually be a run loop in the XPC service. Could you try scheduling the DASession on a dispatch queue instead?


Generally, though, this seems like an issue that it'd be worthwhile to spend a TSI (tech support incident) on. That way you'd have an Apple engineer advising you on what was technically possible. Given the inadequancy of the DiskArbitration documentation, it might be quicker overall to take that approach.

Tat is exactly what was needed.

Thank You !

Te run loop hint helped us look at some posted documentation and pointed us in the correct direction.


https://stackoverflow.com/questions/21937504/using-fseventstream-within-xpc-service-does-not-work