# CocoaPods

Recommend AXM extensions from a CocoaPods (Swift, Objective-C) pod and target CocoaPods packages from an extension.

AXM reads CocoaPods extension metadata from an `agent-extensions.json` sidecar
at the pod root. This is the
[two-way linking](/docs/package-ecosystems/overview) model applied to the
CocoaPods ecosystem.

## Recommend extensions from a pod

Add an `agent-extensions.json` file at the pod root with an `agentExtensions`
array. Each entry is an extension reference (`@owner/<type>/<name>`):

```jsonc
// agent-extensions.json
{
  "$schema": "https://axm.sh/schemas/agent-extensions.schema.json",
  "agentExtensions": [{ "ref": "@examples/packs/swift-cocoapods-tinyflags" }],
}
```

The sidecar must survive `pod install` so AXM can read it at
`Pods/<PodName>/agent-extensions.json`. Keep it by listing it in
`preserve_paths` in your podspec:

```ruby
# AgentXMExampleTinyFlags.podspec
s.preserve_paths = "agent-extensions.json"
```

Keep recommendations **identity-only** — omit `versionRange`. AXM resolves the
reference to the newest matching extension version and pins it in the user's
`axm.lock`. Prefer recommending a single **pack** so you keep one stable
reference while its contents evolve.

Add a semver `versionRange` only when your pod genuinely pairs with a bounded
major line of the extension:

```jsonc
{
  "agentExtensions": [
    {
      "ref": "@examples/packs/swift-cocoapods-tinyflags",
      "versionRange": "^1.0.0",
    },
  ],
}
```

## Target CocoaPods packages from an extension

On the extension manifest (`skill.json`, `pack.json`, `subagent.json`, …), add a
`packages` array with a CocoaPods
[purl](https://github.com/package-url/purl-spec):

```jsonc
// pack.json
{
  "packages": [{ "purl": "pkg:cocoapods/AgentXMExampleTinyFlags" }],
}
```

Use the pod name as published to the CocoaPods trunk as the purl name.

### Version ranges

Default to identity-only. Add a [VERS](https://github.com/package-url/vers-spec)
`versionRange` with the `cocoapods` scheme only when the extension depends on
pod APIs introduced or removed in a known range:

```jsonc
{
  "packages": [
    {
      "purl": "pkg:cocoapods/AgentXMExampleTinyFlags",
      "versionRange": "vers:cocoapods/>=0.1.0|<1.0.0",
    },
  ],
}
```

## Official status

When the pod recommends an extension through the AgentXM Registry **and** that
extension names the pod as a companion via its purl, AXM derives **official**
status for the pair — no extra flag. See
[Official extensions](/docs/package-ecosystems/overview#official-extensions).

## Reference fixture

The
[`swift-cocoapods-lib`](https://github.com/agentxm/polyglot-examples/tree/main/swift-cocoapods-lib)
and
[`swift-cocoapods-app`](https://github.com/agentxm/polyglot-examples/tree/main/swift-cocoapods-app)
directories in `polyglot-examples` are the working fixtures for everything
above. The pod publishes a TinyFlags companion pack and recommends it from the
`agent-extensions.json` sidecar (retained via `preserve_paths`); the pack and
each skill declare the pod's `pkg:cocoapods` purl as an identity-only companion
package.