r/iOSProgramming • u/trikboomie • 29d ago
Question Apple foundation models
If you're using Apple's Foundation Models framework in a released app, how are you debugging issues that only happen on users' devices?
Are Instruments and your existing crash reporting enough, or have you added custom logging?
11
Upvotes
View all comments
Show parent comment
1
u/durul 28d ago
Good list. A few additions for OS 27, from the Xcode 27.2 SDK docs and my own testing:
rateLimitedisn't documented as background-only anymore. The deprecatedGenerationError.rateLimitedsays that, but its OS 27 replacement,LanguageModelError.rateLimited, says it can happen if you make too many requests in a short window, and that the fix may be model-dependent. ThestreamResponsedocs also recommend the non-streamingrespond(to:)when your app is in the background.GenerationErrorisn't caught at all, not just in some cases. Failures arrive asLanguageModelError,SystemLanguageModel.Error,LanguageModelSession.Error(concurrentRequests) andGeneratedContent.ParsingError(the olddecodingFailure). A throwingTool.callarrives asLanguageModelSession.ToolCallError. The iOS 26 list also has a ninth case,unsupportedGuide.Transcript.Response.assetIDs(iOS 26+). Every response carries version-aware ids for the assets that produced it. On macOS 27.2 I got three: tokenizer, draft model and base model, each with a version string. That identifies the model build better than the OS version, and it isn't user data, so it can be a public log field.SystemLanguageModel.variant(27+) andcontextSizeare worth logging too, since AFM 3 Core devices can report a smaller window than Core Advanced.modelNotReadyisn't always a download. On iOS 27.2, with the first preferred language set to one the model doesn't support, I gotmodelNotReadytoo.supportsLocale(_:)onLocale.preferredLanguages.firsttells the two apart. Don't useLocale.current: an English-only app resolved it toen_FI,and the check saidtrue.contextSizeExceededis thrown, so the failing turn isn't there afterward. If you need it, recordsnapshot.usagewhile the stream runs.session.logFeedbackAttachment(sentiment:issues:)sends nothing. It returns JSON with your feedback and the transcript, which you can hand to a share sheet.Also, on OS 27, Apple Intelligence can't be turned off, so
appleIntelligenceNotEnabledonly matters if you still support 26.