iOS USB device access

Hi, all

Accessing USB device on MAC OSX platform, the “App Sandbox”=YES and

”com.apple.security.device.usb”=YES Must be increased to entitlents file.

How to Implement USB Access in iOS Platform?

Replies

iOS does not support access to USB accessories in general. If the accessory connects via a high-level framework, you can talk to it via that framework — for example, you can receive keyboard events from a USB keyboard via UIKit — but there’s no general-purpose USB API.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Add a Comment

Is it possible for iOS 14?

It depends on what you mean by “it”. If you’re asking whether iOS has a general-purpose USB API then, no, it does not.

Share and Enjoy

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

  • Hi. We need to interact with a USB token (USB CCID) from our iOS application using standard Lightning to USB OTG Adapter (MFI) and for iPadOS as well. Applications for other platforms (Windows, Debian, macOS, Android) supporting this USB token have already been made and are successfully working. Of course we are planning to do own PCSC realization like in our Android app.

    Please explain where to find the official documentation on how to do this for iOS, which official framework to use, etc., because I could not find more or less clear information on this. Only info for macOS I could find but it helpless (

    Thanks a lot for any answer.

Add a Comment

using standard Lightning to USB OTG Adapter (MFi)

Please expand on this. Is this something your built? Or you’ve got from another vendor?

[Sorry for the basic questions but MFi isn’t really my thing.]

Share and Enjoy

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

Hi, eskimo

Lightning to USB OTG Adapter is from another vendor. I tried to use CryptoTokenKit in my iOS14+ app to connect to smart card token but I can't to find out how to fix next problem:

this is my simple code

import CryptoTokenKit

let mngr = TKSmartCardSlotManager.default

According official documentation in CryptoLibSwift.entitlements I have added this

com.apple.security.smartcard

but I have this one when app runs

2021-12-22 xxxx CryptoLibSwift[5479:4269434] [smartcard] ctk: connecting to slot registration server (<NSXPCConnection: 0x281271360> connection to service on pid 0 named com.apple.ctkd.slot-client) failed, error Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.ctkd.slot-client was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.ctkd.slot-client was invalidated.}

of course my next code doesn't work but token connected to iPhone

let slotName = mngr?.slotNames[0]

print("slotName:", slotName)

How to fix this?

Thanks.

We’re straying into an area, CryptoTokenKit, that’s not something I maintain expertise in. However, the entitlement you referenced, com.apple.security.smartcard, is documented as being for macOS only. Moreover, I can’t see any way to add this to your provisioning profile’s allowlist (it’s not listed in Xcode’s Signing & Capabilities editor, nor is it in the Capabilities list for an App ID in Developer > Account > Certificates, Identifiers & Profiles).

Share and Enjoy

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

Hi, eskimo

According to this official documentation it is available in iOS 13.0+ (not only macOS) https://developer.apple.com/documentation/cryptotokenkit/tksmartcardslotmanager

How to do this in proper way for iOS?

Were I can find the official example of simple working project/code how to use TKSmartCardSlotManager for iOS?

As I understand only Apple knows how to do this )

Thanks

According to this official documentation it is available in iOS 13.0+

Right. I suspect that the API is present but you can’t access it without the entitlement, which is a macOS-only thing. However, as I mentioned previously, this isn’t really my area of expertise. If you want a definitive answer, you should open a DTS tech support incident and discuss this with DTS’s smart card specialist.

Share and Enjoy

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

Hi, eskimo

I don't understand why it (CryptoTokenKit) is present in iOS13+ without ability to use it?)

We have asked two DSI from different accounts and received absolutely the same helpless answer like this

Follow-up: 792171981

Hello Vitaliy,

Thank you for contacting Apple Developer Technical Support (DTS). We have reviewed your request and have concluded that there is no supported way to achieve the desired functionality given the currently shipping system configurations.

If you would like for Apple to consider adding support for such features, please submit your suggestion request via Feedback Assistant (https://feedbackassistant.apple.com). For more information on Feedback Assistant, please visit https://developer.apple.com/bug-reporting/.

While a Technical Support Incident (TSI) was initially debited from your Apple Developer Program account for this request, we have assigned a replacement incident back to your account.

Best Regards,

Developer Technical Support  Worldwide Developer Relations Apple, Inc.

I’ve been playing around with this myself today. I wrote a small test project that simply fetches TKSmartCardSlotManager.default. This is what I see:

  • On macOS 13, it returns nil unless I sign my app with com.apple.security.smartcard.

  • On iOS 16, I get back a valid value without any entitlement malarkey.

  • On iOS 15, specifically 15.6.1, I always get back nil (and a scary log message :-).

I’m still not completely sure what’s going on here but my best guess is that the pre-iOS 16 behaviour is Just A Bug™.

I’ve filed a bug (r. 102581171) to address the misleading docs.

Share and Enjoy

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