Adapter Problem - compatibleAdapterNotFound

Hello. I have a problem with the FoundationModels adapter and the Apple-hosted managed asset pack via TestFlight.

I have created an adapter that works fine locally by creating a model via (fileURL: URL) on a real device, but I cannot create a model using background assets by downloading the adapter via TestFlight.

Every time I try to get an adapter, the creation of the adapter is interrupted by the compatibleAdapterNotFound error.

The aar. archive i created using a special command - xcrun ba-package foundation-models package
--adapter-path aurelius1.fmadapter
--asset-pack-id fmadapter-aurelius1-9799725
--output-path ./aurelius1.aar
--platforms iOS
--on-demand\

after that, I replaced "OnDemand": null with "OnDemand": {} in the manifest so that the Transporter could send my archive to the App Store Connect.

I followed all the recommendations in this topic - https://origin-devforums.apple.com/forums/thread/823148 ...but unfortunately unsuccessfully

I would appreciate any help in solving this problem.

here is the code that I use in my app -

Answered by Frameworks Engineer in 890074022

Hello, @alex_und3r! Based on the code in the screenshots that you posted, it looks like you’re missing a call to AssetPackManager.ensureLocalAvailability(of:requireLatestVersion:). When you set an asset pack’s download policy to “on demand”, you’re telling the system that it shouldn’t download the asset pack automatically. SystemLanguageModel.Adapter(name:) expects that the asset pack already be downloaded before you call it. To fix the issue here, call ensureLocalAvailability(of:requireLatestVersion:) and wait for it to return successfully before constructing an Adapter instance. I hope that this helps!

if I remove the code that creates the adapter, the background asset is downloaded, therefore the isCompatible(AssetPack) -> Bool method returns true. but it still doesn't help me to get the adapter from the downloaded asset.

I tried to completely copy the dump errors - here are the screenshots

Hello, @alex_und3r! Based on the code in the screenshots that you posted, it looks like you’re missing a call to AssetPackManager.ensureLocalAvailability(of:requireLatestVersion:). When you set an asset pack’s download policy to “on demand”, you’re telling the system that it shouldn’t download the asset pack automatically. SystemLanguageModel.Adapter(name:) expects that the asset pack already be downloaded before you call it. To fix the issue here, call ensureLocalAvailability(of:requireLatestVersion:) and wait for it to return successfully before constructing an Adapter instance. I hope that this helps!

Adapter Problem - compatibleAdapterNotFound
 
 
Q