# Swift Support in Maguyva: Code Graphs for iOS and macOS

Canonical source: https://maguyva.ai/languages/swift

License: text under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); code samples under [MIT-0](https://opensource.org/license/mit-0); the Maguyva name, logos, brand assets and other code are not covered. Details: [maguyva.ai/license](https://maguyva.ai/license).

Maguyva parses Swift with AST, symbol, and graph support, so AI agents can follow protocols, extensions, initializers, and observers in iOS and macOS code.

## Support snapshot

- Tier: AST and symbol support
- Programming
- Extensions: .swift
- Real AST parsing for syntax-aware search and structural context.
- Named symbols feed semantic lookup and cross-reference. Graph navigation is available when relationship extraction is enabled.
- This language contributes symbols and relationships to graph-aware search; supported edge types vary with its native constructs.
- AST parsing and symbol extraction are both available.

## Best fit

- iOS and macOS teams with large app targets and shared Swift packages.
- Codebases built around protocols and extensions, where a type's behaviour is spread across many files.
- Agent workflows that need impact analysis before changing a shared model, service, or protocol.

## Agent workflows

- Find every type that conforms to a protocol before changing one of its requirements.
- Trace callers of a service method across view models, coordinators, and packages.
- Locate initializers, computed properties, and `didSet` observers that touch a piece of state.

## Why Swift needs more than file search

Swift spreads one type across many places. A struct is declared in one file, gains behaviour from extensions in three others, and conforms to protocols defined in a package. State changes hide in computed properties and `willSet` / `didSet` observers. An agent reading files one at a time misses most of that.

Maguyva indexes the structure, so an agent can see a type's members, conformances, and callers together.

## What Maguyva extracts in Swift

Maguyva covers `.swift`. Callable symbols include functions, `init` and `deinit`, subscripts, computed getters and setters, and `willSet` / `didSet` observers, so state-changing code is searchable as symbols rather than buried in property bodies.

Members declared inside structs, enums, protocols, and extensions are qualified by their owning type (for example `CartStore.add`), and members added in an extension are attributed to the extended type. Definition names have generic parameters, protocol conformance lists, and `?` / `!` suffixes stripped, so lookups use the plain name. Calls keep `self.` and class qualification, and trailing closures count toward call arity.

The graph records calls, protocol conformance, inheritance, overrides, instantiation, attributes, type references, reads and writes, and `throw` edges.

## Example agent prompts

- "Which types conform to `PaymentProvider`, and where is each one created?" (`dependency_search`)
- "Who calls `CartStore.add`, and from which views?" (`find_symbol`, then `dependency_search` incoming)
- "Explain how a push notification reaches the inbox screen." (`get_task_context`)

## Known limits

- Only `.swift` source is mapped. Storyboard and XIB files are not in the extension list, so Interface Builder connections are outside the graph.
- Standard-library and Foundation calls such as `print`, `debugPrint`, `NSLog`, and assertions are filtered from relationships, so they are not graph edges. Use `text_pattern_search` for them.

## Next steps

Connect a repository with the [quickstart](/docs/quickstart), then check the support matrix on the [compatibility page](/docs/compatibility). If you ship the same product on Android, read the [Kotlin guide](/languages/kotlin).

## Engine details

- Callable symbols include functions, `init`, `deinit`, subscripts, computed getters and setters, and `willSet` / `didSet` observers.
- Members of structs, enums, protocols, and extensions are qualified by their owning type, such as `CartStore.add`.
- Generic parameters, protocol conformance lists, and `?` / `!` suffixes are stripped from definition names, and calls keep `self.` and class qualification.

## Useful MCP entry points

- `find_symbol`: Use it for a type, protocol, or method name when you need the definition and references.
- `dependency_search`: Use it on a protocol to find conforming types, or incoming on a method to find callers.
- `get_task_context`: Use it for prompts like “explain how a push notification reaches the inbox screen.”
