CryptoTokenKit: TKSmartCardSlotManager.default is nil on macOS (Designed for iPad) but works on iPadOS and macOS

I have an iOS/iPadOS app and 'm trying to communicate with usb smart card reader using CryptoTokenKit on all platforms (ios/ipados/macos).

Minimal Repro Code

import CryptoTokenKit
import SwiftUI

struct ContentView: View {
@State var status = ""
var body: some View {
    VStack {
        Text("Status: \(status)")
    }
    .padding()
    .onAppear {
        let manager = TKSmartCardSlotManager.default
        if manager != nil {
            status = "Initialized"
        } else {
            status = "Unsupported"
        }
    }
}

}

And my entitlement file has only one key: com.apple.security.smartcard = YES

Behavior

•	iPadOS (on device): status = "Initialized" ✅
•	macOS (native macOS app, with the required CryptoTokenKit entitlement): status = "Initialized" ✅
•	macOS (Designed for iPad, regardless of CryptoTokenKit entitlement): status = "Unsupported" → TKSmartCardSlotManager.default is nil ❌

Expectation

Given that the same iPadOS build initializes TKSmartCardSlotManager, I expected the iPad app running in Designed for iPad mode on Apple silicon Mac to behave the same (or to have a documented limitation).

Questions

  1. Is CryptoTokenKit (and specifically TKSmartCardSlotManager) supported for iPad apps running on Mac in Designed for iPad mode?

  2. If support exists, what entitlements / capabilities are required for USB smart-card access in this configuration?

  3. If not supported, is Mac Catalyst the correct/only path on macOS to access USB smart-card readers via CryptoTokenKit?

  4. Are there recommended alternatives for iPad apps on Mac (Designed for iPad) to communicate with USB smart-card readers (e.g., ExternalAccessory, DriverKit, etc.), or is this scenario intentionally unsupported?

Thanks!

Answered by DTS Engineer in 864963022

That’s annoying, but not super surprising. There are subtle differences in how smartcards are supported on iOS and macOS, and this support was added before iOS Apps on Mac was a thing, so it’s easy to see how this might work for native apps but fail for an iOS app running on the Mac.

Still, it’s reasonable to expect that this should work out of the box — I mean, that’s the whole reason the iOS Apps on Mac feature exists — and so it’d make sense for you to file a bug about this.

Please post your bug number, just for the record.

is Mac Catalyst the correct/only path on macOS

That depends on whether your app is wedded to UIKit or not. The example you posted used SwiftUI, and if your app also uses SwiftUI then you have two choices:

  • Use Mac Catalyst, resulting in SwiftUI on top of UIKit on Mac.
  • Create a multi-platform SwiftUI app, resulting in SwiftUI on top of AppKit on Mac.

Personally, I think the latter is the better option, but I know that some developers achieve good results with the former.

Share and Enjoy

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

Accepted Answer

That’s annoying, but not super surprising. There are subtle differences in how smartcards are supported on iOS and macOS, and this support was added before iOS Apps on Mac was a thing, so it’s easy to see how this might work for native apps but fail for an iOS app running on the Mac.

Still, it’s reasonable to expect that this should work out of the box — I mean, that’s the whole reason the iOS Apps on Mac feature exists — and so it’d make sense for you to file a bug about this.

Please post your bug number, just for the record.

is Mac Catalyst the correct/only path on macOS

That depends on whether your app is wedded to UIKit or not. The example you posted used SwiftUI, and if your app also uses SwiftUI then you have two choices:

  • Use Mac Catalyst, resulting in SwiftUI on top of UIKit on Mac.
  • Create a multi-platform SwiftUI app, resulting in SwiftUI on top of AppKit on Mac.

Personally, I think the latter is the better option, but I know that some developers achieve good results with the former.

Share and Enjoy

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

Filled a bug: FB21101973

CryptoTokenKit: TKSmartCardSlotManager.default is nil on macOS (Designed for iPad) but works on iPadOS and macOS
 
 
Q