Thread Network API not working

I'm trying to use ThreadNetwork API to manage TheradNetworks on device (following this documentation: https://developer.apple.com/documentation/threadnetwork/), but while some functions on THClient work (such as getPreferedNetwork), most don't (storeCredentials, retrieveAllCredentials). When calling these functions I get the following warning/error:


Client: -[THClient getConnectionEntitlementValidity]_block_invoke - Error:

-[THClient storeCredentialsForBorderAgent:activeOperationalDataSet:completion:]_block_invoke:701: - Error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 414 named com.apple.ThreadNetwork.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service with pid 414 named com.apple.ThreadNetwork.xpc was invalidated from this process.}

Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 414 named com.apple.ThreadNetwork.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service with pid 414 named com.apple.ThreadNetwork.xpc was invalidated from this process.}

Failed to store Thread credentials: Couldn’t communicate with a helper application.

STEPS TO REPRODUCE

  1. Create new project

  2. Add Thread Network capability via Xcode UI (com.apple.developer.networking.manage-thread-network-credentials)

  3. Trigger storeCredentials


let extendedMacData = "9483C451DC3E".hexadecimal

let tlvHex = "0e080000000000010000000300001035060004001fffe002083c66f0dc9ef53f1c0708fdb360c72874da9905104094dce45388fd3d3426e992cbf0697b030d474c2d5332302d6e65773030310102250b04106c9f919a4da9b213764fc83f849381080c0402a0f7f8".hexadecimal

// Initialize the THClient

let thClient = THClient()

// Store the credentials

await thClient.storeCredentials(forBorderAgent: extendedMacData!, activeOperationalDataSet: tlvHex!) { error in

if let error = error {

print(error)

print("Failed to store Thread credentials: \(error.localizedDescription)")

} else {

print("Successfully stored Thread credentials")

}

}

NOTES:

  • I tried with first calling getPreferedNetwork to initiate network permission dialog

  • Tried adding meshcop to bojur services

  • Tried with different release and debug build configurations

I'm trying to use ThreadNetwork API to manage TheradNetworks on device (following this documentation: https://developer.apple.com/documentation/threadnetwork/), but while some functions on THClient work (such as getPreferedNetwork), most don't (storeCredentials, retrieveAllCredentials). When calling these functions I get the following warning/error:

A few different questions here:

  • What system are you running on (iOS vs. mac) and is your code running directly in your app or is it in an extension point? If it's in an extension point, I would recommend getting this working properly in the app context first.

  • Is thread itself "working"? For example, do you have a Matter over Thread accessory paired and working in HomeKit?

  • Have you captured a sysdiagnose and look at the failure in the broader console log to see what as logged there?

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Yes, I captured sysdiagnose logs, but I was unable to locate any error or log that would relate to this issue

Please file a bug on this, upload the sysdiagnose there, then post the bug number back here.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Hi, I have filed a bug report as requested: https://feedbackassistant.apple.com/feedback/16942195

Hi, is this still an issue? Having the same problem on iOS 26.1

Hi, is this still an issue? Having the same problem on iOS 26.1

Are you actually running the same code as the developer above? The failure above is a very "general" failure that doesn't necessarily have any single cause. Indeed, in the case above, I don't think there was any bug, as the initial sysdiagnose analysis seems to indicate that this is actually caused by an issue with how THClient is being managed, mostly that it's being used inside a dispatch block without being properly retained by any "larger" infrastructure. So what's actually happening is that the THClient is being torn down when the block is destroyed, before it can properly "do" any of its expected work.

If you're specifically using Swift, try storing your THClient reference as a member variable of an object, not as a local reference inside a block. I haven't fully validated this, but I think there's an oddity in THClients design such that Swift async methods may fail earlier than they should because THClient is allowing itself to deallocate.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Thread Network API not working
 
 
Q