Swift Package Manager plugin: compile intents automatically on build
Axint integrates with SPM as a build plugin. Add it to Package.swift and your TypeScript intents compile to Swift on every build.
If your app is a Swift Package, you can now add Axint as a build plugin. When you build, TypeScript intent files compile to Swift automatically. No scripts, no Makefile, no manual steps.
Setup
Add Axint to Package.swift:
swift let package = Package( name: "MyApp", targets: [ .target( name: "MyApp", dependencies: [ .product(name: "AxintPlugin", package: "axint"), ], plugins: [ .plugin(name: "AxintBuildPlugin", package: "axint"), ] ), ] )
That's it. Put .intent.ts files in your Sources directory. They compile on build.
What happens
The plugin scans your package for .intent.ts files, runs axint compile on each, and emits Swift into a generated directory that SPM includes in the build. Your intent structs are available to import in your Swift code.
Sources/ MyApp/ SearchIntent.intent.ts CreateIntent.intent.ts App.swift
Builds to:
.build/plugins/outputs/AxintPlugin/Generated/ SearchIntent.swift CreateIntent.swift
Imported automatically. No manual file management.
Diagnostics in Xcode
[Validation errors](/blog/validator-architecture) surface as compiler errors in Xcode's Issue Navigator:
error: [Axint AX003] Parameter 'query' has no title. (SearchIntent.intent.ts:12:5)
Same error stream as Swift compiler errors. One place to check.
How the plugin works
It's a standard SPM BuildToolPlugin:
```swift @main struct AxintBuildPlugin: BuildToolPlugin { func createBuildCommands( context: PluginContext, target: Target ) async throws -> [Command] { let inputs = target.sourceModule?.sourceFiles .filter { $0.path.extension == "intent.ts" } .map(\.path) ?? []
if inputs.isEmpty { return [] }
let outputDir = context.pluginWorkDirectory.appending("Generated")
return [ .buildCommand( displayName: "Compiling Axint intents", executable: try context.tool(named: "axint").path, arguments: ["compile", "--output", outputDir.string] + inputs.map(\.string), outputFiles: [outputDir] ), ] } } ```
Discovers intent files, invokes the CLI, tells SPM where the output lives. SPM handles caching — if your intent files don't change, the plugin doesn't re-run.
Requirements
The Axint CLI needs to be installed and in PATH. For CI, add npm install -g @axint/compiler to your build config. Axint Cloud will remove this requirement once it ships — the plugin will compile remotely if the CLI isn't available locally.
Monorepo support
The plugin works with workspace packages. Each package target can have its own intent files, and they all compile independently. Import [entity definitions](/blog/entity-queries-deep-dive) across packages using the standard SPM dependency graph.
For non-SPM projects (Xcode project files), we're building Xcode Build Rules support next. Same idea — automatic compilation on build — but using Xcode's native build rule system instead of SPM plugins.