GlassModelPicker
| Identifier | glass-model-picker |
| Module | SPGlassAI |
| Kind | native-wrapper — the system draws the Menu and its rows |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/AI/GlassModelPickerExample.swift |
UI only: the list of models and their states are supplied by the host. The picker downloads nothing and contacts no provider.
Minimal usage
@State private var modelID: String? = "small"
GlassModelPicker(models: models, selection: $modelID)Variants
| Availability | Row |
|---|---|
.local |
"On device · Text, Vision" |
.remote |
"Remote · Text, Tools" |
.unavailable(reason:) |
Disabled, "Unavailable · Not downloaded" |
Models are grouped in sections by provider. The menu's label is the selected model's name with a symbol for where it runs, or the title when nothing is selected.
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
title |
LocalizedStringKey? |
"Model" | Accessibility label, and visible title when nothing is selected. |
models |
[GlassModelInfo] |
— | id, name, provider, capabilities, availability. Any order. |
selection |
Binding<String?> |
— | Identifier of the selected model. |
GlassModelCapabilities is an option set: .text, .vision, .tools, .reasoning, .audio, .code. Each has a localised name and a symbol (descriptors) for hosts that draw their own summary.
States
- Selected: the row carries the system checkmark (each row is a
Toggleinside the menu). - Unavailable: the row is disabled and gives the reason in words.
- No selection: the label shows the title.
- Empty list: the menu is disabled.
Sorting and grouping are GlassModelCatalog.grouped(_:): providers alphabetically; inside a provider, selectable models first, then by name with numeric-aware comparison; a repeated identifier keeps its first occurrence.
Advanced example
struct ModelToolbarItem: ToolbarContent {
let registry: ModelRegistry // host type
@Binding var selection: String?
var body: some ToolbarContent {
ToolbarItem(placement: .principal) {
GlassModelPicker("Model", models: registry.models.map { model in
GlassModelInfo(
id: model.id,
name: model.displayName,
provider: model.vendor,
capabilities: model.supportsImages ? [.text, .vision] : [.text],
availability: model.isDownloaded ? .local : .unavailable(reason: "Not downloaded")
)
}, selection: $selection)
}
}
}Accessibility
- The menu is labelled with the title; its value is the selected model's name, where it runs and its capabilities.
- Capabilities and availability are written in words in every row; symbols are never the only carrier.
- Unavailable rows are disabled by the system and state the reason.
- Everything else (keyboard navigation, VoiceOver, Dynamic Type) is the system menu's behaviour.
Limits
- How a second line of text is displayed in a menu row is decided by the platform; the text is always available to assistive technologies.
- The picker does not validate that
selectionexists inmodels; an unknown identifier shows the title. - No search field: for long catalogues present a searchable list in a sheet instead.
- The rendering of the menu was not inspected in a running application during verification; grouping, sorting and wording are unit-tested.