Detect if the current device supports DriverKit?

When we ship an iOS app with a DriverKit driver bundled, we'd like to be able to check if the device the app is running on is actually capable of installing & running DriverKit drivers. However I have yet to find a reliable way to achieve this. We want to know before the driver has even been enabled, as we want to direct the user to enable it in the app's settings.

I have tried a few things to no avail, and lots of it has just been unmaintainable guesses at which device the app is running on, rather than checking directly if DriverKit is actually available.

Is there any suggested way of achieving this? Thanks!

When we ship an iOS app with a DriverKit driver bundled, we'd like to be able to check if the device the app is running on is actually capable of installing and running DriverKit drivers. However, I have yet to find a reliable way to achieve this. We want to know before the driver has even been enabled, as we want to direct the user to enable it in the app's settings.

First off, please file a bug on this and post the bug number back here. We really should have an API for this, and even if the solution below works, the behavior isn't documented as such, so I can't guarantee it will work (or continue to work if it does).

In any case, in iOS 18.4, we added the API "systemExtensions(forApplicationWithBundleID:)". While it isn't explicitly stated as such, what the API actually returns is the DEXT inside an app’s bundle set and their enablement state.

However, the other useful detail here is that on devices that don't support DriverKit, I THINK (but haven't had a chance to test) that it will actually end up returning "NULL"*, due to how its internal error handling works.

*Note that your app will also need to include the System Extension Entitlement for the API function.

As I said, I haven't had a chance to test this, but it's worth trying, since you'll probably end up using the API anyway.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Hi Kevin,

Thanks for getting back to me on this one. I've been trying to do as you advised, but I'm hitting an error which gives the impression it's coming from the SystemExtensions API, but I could just be misunderstanding what it's trying to tell me.

I am attempting to run this code after importing the SystemExtensions framework (I've removed protections here):

      guard let bundleID = Bundle.main.bundleIdentifier else {
          print("Bundle identifier is nil")
          return NSNumber(value: false)
      }

      let workspace = OSSystemExtensionsWorkspace.shared
      
      let extensions = try workspace.systemExtensions(forApplicationWithBundleID: bundleID)
      print("Extensions: \(extensions)")
      return NSNumber(value: true)

but I hit this error:

Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]' was thrown while invoking isDriverKitSupported on target CheckDriverKitCapabilities with params (
)
callstack: (
	0   CoreFoundation                      0x0000000184e4c0cc 7BB5DC02-A4C7-3E6C-9C46-E79FF100E027 + 1155276
	1   libobjc.A.dylib                     0x00000001822e9abc objc_exception_throw + 88
	2   CoreFoundation                      0x0000000184e3aa7c 7BB5DC02-A4C7-3E6C-9C46-E79FF100E027 + 1084028
	3   CoreFoundation                      0x0000000184d5cb40 7BB5DC02-A4C7-3E6C-9C46-E79FF100E027 + 174912
	4   SystemExtensions                    0x00000002464ed254 7E1C5B8B-3068-3126-A895-BFCA62BE8124 + 4692
	5   Test App                          0x00000001057f61b8 $s10Test_App28CheckDriverKitCapabilitiesSwiftC08isDriverD9SupportedSo8NSNumberCyFTf4d_n + 668
	6   Test App                          0x00000001057f5e58 $s10Test_App28CheckDriverKitCapabilitiesSwiftC08isDriverD9SupportedSo8NSNumberCyFTo + 12
	7   Test App                          0x00000001043841b8 -[CheckDriverKitCapabilities isDriverKitSupported] + 104

This is when running on an iPad Pro (12.9 inch) (6th generation) running iPadOS 18.6. I've added the com.apple.developer.system-extension.install entitlement to the app.

Am I trying to do this incorrectly?

I will of course file a ticket to request a proper API to check for DriverKit support, just trying to verify if this potential workaround works or not first.

Thanks for getting back to me on this one. I've been trying to do as you advised, but I'm hitting an error which gives the impression it's coming from the SystemExtensions API, but I could just be misunderstanding what it's trying to tell me.

Please file a bug on this, attach the crash logs to that bug, then post the bug number back here. FYI, I'll be on vacation next week, but I'll try and take a look at this when I get back.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Detect if the current device supports DriverKit?
 
 
Q