r/iOSProgramming • u/trikboomie • 17d 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?
1
u/jrkral2 10d ago
Adding an angle the thread hasn't covered: apps where nothing can leave the device at all. I'm the developer of Faraday, a therapy-notes app built on Foundation Models, and the privacy model is that session content never leaves the phone, so even the counts-only remote layer suggested above is something I'd rather not depend on.
What I'd suggest in that situation:
Keep a small local diagnostics log (OSLog with privacy: .private on anything content-derived, plus a ring buffer in the app container) with availability state, the error case, input token estimate vs. the context limit, chunk index, OS build and locale. No prompt or output text.
Give the user an "export diagnostics" button that shows them exactly what's in it before they share it, by email or however they choose. They decide, and you get the same fields you would have logged remotely.
exceededContextWindowSize and guardrailViolation are the two cases I'd expect most in the field, and both tend to reproduce locally once you know the input length and locale, so logging lengths gets you a long way.
Test a TestFlight build on a real device with Apple Intelligence turned off and with the model assets not yet downloaded. availability returns different unavailable reasons, and those paths are easy to miss in the simulator.
1
u/trikboomie 8d ago
Really useful angle, thanks. For Faraday, how often do users actually hit "export diagnostics", and has a shared export ever let you fix something you couldn't reproduce otherwise? If a local-only diagnostics library existed that never phoned home, would you use it, or would you still rather own that code?
1
u/jrkral2 5d ago
Honest answer: too early to tell. Faraday is new, and since it has no analytics I only find out about an export when someone chooses to send one, which hasn't happened often enough to say anything useful yet. So I can't claim a shared export has caught something I couldn't reproduce.
On the library: I'd look at it, but I'd probably still want to own that code. For an app like this the thing that matters is the guarantee that nothing leaves the device unless the user sends it, and that's easier to reason about, and to square with the privacy label, when I control every line. If it were small, had no dependencies and no networking code at all, so you could confirm that with a quick search of the source, that would make it a lot easier to say yes.
2
u/rhugopinon 17d ago
Xcode 27 actually added a new built-in tool called "Evaluations" for debugging Foundation Models in your app. Pretty handy if you need to trace model behavior.
1
1
1
u/Needle_In_Red 16d ago
+1 on logging the availability state. id also log the OS version and device locale with it, alot of the weird stuff is just the model not being ready yet or the language not supported and crash reports wont show you any of that
5
u/Significant_Door_433 17d ago •
Instruments only helps on devices you can plug in, so for the field you need your own logging. The things worth capturing:
Availability. Log SystemLanguageModel.default.availability at launch and before you open a session. The unavailable reasons are deviceNotEligible, appleIntelligenceNotEnabled and modelNotReady. modelNotReady is the sneaky one, the model can still be downloading after an OS update.
The error case, not only the localized message. On iOS 26 it's LanguageModelSession.GenerationError (exceededContextWindowSize, guardrailViolation, decodingFailure, refusal, rateLimited, concurrentRequests, unsupportedLanguageOrLocale, assetsUnavailable). Built with Xcode 27 and running on 27, some failures come as LanguageModelError or SystemLanguageModel.Error instead, so match on all of them or half your logs end up as "unknown".
OS build and locale next to every model log. The model ships with the OS, so the same prompt can behave differently after an update, and unsupportedLanguageOrLocale only shows up for some users.
Two cases look random in crash reports but aren't. rateLimited only happens when the app is in the background. assetsUnavailable can fire mid-session if the user turns Apple Intelligence off or the device deletes the model to free space.
For the content itself, session.transcript has the full history (instructions, prompts, tool calls, responses). I wouldn't upload that by default since prompts are user data. Keep the last transcript on device and attach it only to a user-sent bug report, and keep prompt text private in os Logger (the default for interpolated strings, just never mark it .public).