The Foundation Models framework in iOS 26 introduces @Generable and @Guide macros that automatically convert unstructured language model responses into typed Swift structs. The @Generable macro marks structs for automatic conversion, while @Guide provides specific instructions to the model for generating properties like array counts and descriptions. A vocabulary quiz app demonstrates how to generate structured Question objects with text, choices, answers, and explanations directly from model output, eliminating manual parsing.

6m read timeFrom appcoda.com
Post cover image
Table of contents
The Demo AppUsing @Generable and @GuideBuilding the Quiz AppSummary

Sort: