DriverKitUserClientSample
A working DriverKit sample with iPadOS and macOS targets, adapted from Apple's WWDC example.
Install / Use
/learn @DanBurkhardt/DriverKitUserClientSampleREADME
DriverKitUserClientSample
An updated version of Apple's DriverKit sample project "DriverKitUserClientSample" with iPadOS support.
Updates:
- Outdated DriverKit Framework usage updates
- Implemented suport for iPadOS targets
- Implemented WWDC '22 Swift UI approach on adding iPad support to macOS DriverKit driver
Bug Fixes / Enhancements
- Implemented default running of client in terminal vs Xcode
- A workaround that fixes an issue where you can't send text input to C++ client via command line while running it.
This project was adapted from Apple's WWDC sample project with many, many updates, fixes, and with iPadOS implementation added.
Usage
System Extension Utils
-
Check if SIP is enabled or disabled (disable if you don't have a DriverKit entitlement from Apple)
csrutil status
-
Enable developer mode:
systemextensionsctl developer on
-
list all currently installed system extensions with status
systemextensionsctl list
-
uninstall a system extension
systemextensionsctl uninstall $(DEV_TEAM_ID) $(com.yourext.bundleid.app)
Troubleshooting, Tips, & Credits
Tips
-
Keep in mind that the published Example Projects are super out of date (as of at least Oct 2023).
-
Highly recommend that if you follow the example / guide "Connecting a network driver" that you do NOT do any of the manual steps related to registering and generating a provisioning profile
- It WILL work if you do it but you do not need to (the documentation is outdated)
- Since Xcode 14, Xcode is able to do this automatically for DriverKit, just as it would for any other type of provisioning profile
-
BIG side note / tip for iPadOS drivers:
-
If you plan to embed your DriverKit Driver in an iPadOS app, your bundle naming convention MUST follow this exmple, or it will not compile:
- Application target bundle id:
com.reversedomainscheme.exampleapp - DriverKit target bundle id:
com.reversedomainscheme.exampleapp.driver - (notice that the app target's bundle ID is used as a prefix for the driver target's bundle id)
- Application target bundle id:
-
TL;DR: the driverkit bundle ID is required to use the application bundle id as a prefix. - Note: You don't have to use ".driver" as a suffix, you can use whatever you want to call it, just remember that your driver will be referred to by the driver bundle id in future operations.
-
Source project from Apple:
- https://developer.apple.com/documentation/driverkit/communicating_between_a_driverkit_extension_and_a_client_app
- Note: this walkthrough has a LOT of inconsistencies, outdated implementation stuff, and is missing things like iPad support being enabled.
WWDC References:
Apple Developer Forum: Issues and Resolutions
-
Issue: Unable to run existing application after adding and embedding a DriverKit target
- I had this exact issue, same as posted on the official developer forums
- Local env: macOS Ventura 13.5.1 (22G90), Xcode 15 (latest, and latest Swift version), macOS app target version: 12.*^
- Solution:
- I tried every single possible thing to fix this and nothing at all worked. It was maddening-- I have NO IDEA what was proventing me from just embedding a new DriverKit driver target into my app-- I tried EVERYTHING possible, including re-installing Xcode completely, with a full purge and re-load, full reload of
xcode-select --installas well. - The only thing that worked create a new application target, embed / link the new DriverKit target to the new application target, and then literally just select every single file from the original project and add them all to the new application target.
- After adding all source code and manually updating the application info.plist, entitlements, etc. it was fine, everything worked. I must underline again, everything you can possibly check between these two targets is configured identically, this is just a troll in the machine somewhere.
- I tried every single possible thing to fix this and nothing at all worked. It was maddening-- I have NO IDEA what was proventing me from just embedding a new DriverKit driver target into my app-- I tried EVERYTHING possible, including re-installing Xcode completely, with a full purge and re-load, full reload of
-
Issue: Unable to type text to your client when running it with Xcode
Youtube References:
- From apple dev forum on "can't type input into Xcode" (for C++ app)
- https://www.youtube.com/watch?v=l_h3P9VbsJc
Credits
- A sincere thanks to Apple for publishing all of this content, and for having and maintaing by far the best developer resources and documentation in the industry.
- It is understandably difficult to keep everything up to date, please don't interpret anything here as unfair criticism.
- I do, however, think that it would be great if we devs could just do a PR on these example projects to help you all keep them updated.
- Please consider publishing and sharing via Github vs the static DocC documentation site.
- The example projects are helpful, but they are also sometimes a hinderence when they fall behind the latest changes & improvements.
(Everything below was the original content of the example project readme) <br>
Communicating Between a DriverKit Extension and a Client App
Send and receive different kinds of data securely by validating inputs and asynchronously by storing and using a callback.
Overview
This sample code project shows how a DriverKit extension (dext) receives data from a C++ client process. The sample handles both scalar data and structures, and has two code paths for each type: an insecure version, and a "checked" version that validates traits like data size and input count.
The sample also demonstrates registering and executing a callback function, so the driver can call the client asynchronously.
The sample project contains three targets:
DriverKitSampleApp- A macOS app, written with SwiftUI, to install or update the driver.NullDriver- The dext itself, which responds to client calls and optionally checks that each call sends the expected data.CppUserClient- A terminal-based client application that calls the driver.
Configure the Sample Code Project
To run the sample code project, you first need to build and run DriverKitSampleApp, which installs the driver. After that, you can build and run CppUserClient, which calls the newly-installed driver.
You can set up the project to build with or without entitlements. To build without entitlements, do the following:
- Temporarily turn off SIP, as described
Related Skills
node-connect
353.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
353.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
353.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
