Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Proper way to use IOKit in iOS app?

Hello, forum, I'm trying to build connection between a non-MFi HID device (like keyboard) and iOS app with IOKit and Swift.

Thanks to this post, I have manage to import the IOKit into objc header.

IOKit on iOS/iPadOS 16.0+

#import <IOKit/IOKitLib.h>

However, I have this compiler error when I try to imitate same methods in the SerialPortSaple project from following article, but the IOKit can not be imported to Swift at first place.

Communicating with a Modem on a Serial Port

The screen shot of the sample project:

It looks like the complier unable to reach the io_object_t type somehow, is there any workaround or approach?

Answered by DTS Engineer in 790241022

I/O Kit on non-Mac platforms is only rated for talking to a DriverKit driver. You can’t use it to talk to generic hardware. Moreover:

  • DriverKit is only supported on iPadOS, not iOS.

  • The DriverKit driver controls whether your app can use it, via the entitlements listed here.

Share and Enjoy

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

Accepted Answer

I/O Kit on non-Mac platforms is only rated for talking to a DriverKit driver. You can’t use it to talk to generic hardware. Moreover:

  • DriverKit is only supported on iPadOS, not iOS.

  • The DriverKit driver controls whether your app can use it, via the entitlements listed here.

Share and Enjoy

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

Thanks @DTS Engineer ! So there are no other alternatives besides the MFi program if I want to build communication over USB-C for iOS and a keyboard HID device?"

So there are no other alternatives besides the MFi program if I want to build communication over USB-C for iOS and a keyboard HID device?

On iOS (as opposed to iPadOS) there are only two ways to work with accessories over USB:

  • If the accessory is supported by iOS itself, you can use high-level APIs to work with it. For example, you can work with a keyboard using both UIKit and Game Controller framework.

  • If not, your only option is MFi. Last I checked that requires you to build your accessory to support MFi.

Share and Enjoy

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

On iOS (as opposed to iPadOS) there are only two ways to work with accessories over USB:

Thanks eskimo, your reply is pretty straightforward and that's what I need!

Last I checked that requires you to build your accessory to support MFi.

Yes, and the previous accessory was released successfully, appreciate that :-)

We're planning our new module for USB-C iPhone, and I need to evaluate every possibility for bridging an iOS device and our new barcode reader for our team, just some context :))

Hi! is there any new update about comminucating between typc-c iphone and modules?

See Kevin’s answer on the the new thread that you opened about this.

Share and Enjoy

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

Proper way to use IOKit in iOS app?
 
 
Q