DriverKit on iOS - can't actually communicate with a driver in seed 1?

I watched the session multiple times, but it just gives a high level overview that doesn't really say much about this very exciting and complex new feature. It only mentions actually talking to the driver in passing with a single sentence "apps use the IOKit framework to open user clients". Then the presenter says for an example of that we can check out "communicating between a driverkit extension and a client app", which is a macOS app that doesn't even use IOKit, and trying to import IOKit into an iPadOS target doesn't work anyway because the framework is not there.

Am I missing something, or is this simply not available in Xcode 14 seed 1? Release notes don't mention anything either, and docs are only updated to reflect that some of this stuff is now available on iPadOS 16...

Replies

Then the presenter says for an example of that we can check out "communicating between a driverkit extension and a client app", which is a macOS app that doesn't even use IOKit...

The "CppUserClient" target does use IOKit, as it is the part of the sample that communicates with the Dext.

and trying to import IOKit into an iPadOS target doesn't work anyway because the framework is not there.

Unfortunately, the IOKit headers for iPadOS are not available in Seed 1.

Unfortunately, the IOKit headers for iPadOS are not available in Seed 1.

Yep )-:

Until this bug (r. 94509285) is fixed you can work around it by copying the I/O Kit headers from the macOS SDK to the iOS SDK. See the scripts pasted in below.

WARNING Copying headers between SDKs is not a supported technique in general and can cause a wide array of problems. Use this technique solely to work around the above-mentioned bug.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"


% cat IOKit_iOS_headers_install.sh 
#!/usr/bin/env sh

set -e

echo "Will install IOKit headers into Xcode: $(xcode-select -p)"
read -p "Press any key to continue, or Ctrl-C to cancel"

echo "Copying IOKit.framework headers to iOS SDK"
cd $(xcrun -sdk iphoneos -show-sdk-path)/System/Library/Frameworks/IOKit.framework
mkdir -p Versions/A/Headers
cp $(xcrun -sdk macosx -show-sdk-path)/System/Library/Frameworks/IOKit.framework/Headers/{IOTypes.h,IOKitKeys.h,IOMessage.h,IOReturn.h,IODataQueueShared.h,IODataQueueClient.h,OSMessageNotification.h,IOCFUnserialize.h,IOMapTypes.h,IOCFSerialize.h,IOKitLib.h} Versions/A/Headers
ln -s Versions/A/Headers Headers

echo "Copying IOKit.framework headers to iOS simulator SDK"
cd $(xcrun -sdk iphonesimulator -show-sdk-path)/System/Library/Frameworks/IOKit.framework
mkdir -p Versions/A/Headers
cp $(xcrun -sdk macosx -show-sdk-path)/System/Library/Frameworks/IOKit.framework/Headers/{IOTypes.h,IOKitKeys.h,IOMessage.h,IOReturn.h,IODataQueueShared.h,IODataQueueClient.h,OSMessageNotification.h,IOCFUnserialize.h,IOMapTypes.h,IOCFSerialize.h,IOKitLib.h} Versions/A/Headers
ln -s Versions/A/Headers Headers

% cat IOKit_iOS_headers_remove.sh 
#!/usr/bin/env sh

set -e

echo "Will remove IOKit headers from Xcode: $(xcode-select -p)"
read -p "Press any key to continue, or Ctrl-C to cancel"

echo "Removing IOKit.framework headers from iOS SDK"
cd $(xcrun -sdk iphoneos -show-sdk-path)/System/Library/Frameworks/IOKit.framework
rm -rf Versions/A/Headers Headers

echo "Removing IOKit.framework headers from iOS simulator SDK"
cd $(xcrun -sdk iphonesimulator -show-sdk-path)/System/Library/Frameworks/IOKit.framework
rm -rf Versions/A/Headers Headers

Just closing the loop here…

As far as I can tell this bug was fixed in Xcode 14.0b2. If you continue to see problems, please let us know.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo, It looks like it's not fixed. I tested on Xcode - Version 14.0 beta 3 (14A5270f), macOS 12.5

Steps:

  1. Created new iOS project
  2. On General tab -> Frameworks, Libraries and Embedded Content clicked +
  3. Found and added IOKit.framework
  4. Added import IOKit in ContentView.swift

Actual result: complier error - No such module IOKit

Same it's happening to me, I can't use IOKit framework. I've followed the same steps posted by @myurik2

Workaround: I imported IOKit #import <IOKit/IOKitLib.h> into Objective-C code and successfully complied my code. But I think issue should be fixed for Swift import IOKit since using Objective-C in 2022 is not a good option.

Unfortunately, IOKit is only available via the Objective-C headers for now. You will not be able to import it via Swift.