# Static Feed & Channel Spec

A **Channel** is a directory of four static files at one HTTPS location. That is the whole protocol: no dynamic application is required, any static host works, and the Host App reads one small JSON file to decide whether an update exists.

This chapter explains the contract for people who publish with the `iosparkle` tool or write their own publisher. The normative, self-contained version — with the JSON Schema, full test vectors, and a verification checklist — is [`docs/agent/channel-spec.md`](agent/channel-spec.md). Both describe the same protocol; when in doubt, that file is the reference.

## The Channel directory

```text
https://ota.example.com/my-app-dev/
├── feed.json         the Feed: what the current build is
├── manifest.plist    how iOS installs it
├── app-118.ipa       the package itself
└── index.html        first-time install page
```

| File | Purpose | Replaced by each publish |
| --- | --- | --- |
| `feed.json` | The **Feed**, a v1 JSON document with the current build's metadata. | Yes |
| `manifest.plist` | The install manifest that iOS reads to locate and verify the package. | Yes |
| `app-<build>.ipa` | The package, named after its build number. | No — a new build gets a new file |
| `index.html` | Landing page for installing the first build from Safari. | Yes |

### Naming and retention

The package is `app-<build>.ipa`, where `<build>` is the package's `CFBundleVersion`: `app-118.ipa`. The name never changes for a given build, and the file at that name never changes its contents. That buys two things at once:

- A device resuming an interrupted download with a `Range` request always continues from the same bytes.
- The file can be cached forever (`Cache-Control: public, max-age=31536000, immutable`).

Each publish keeps the new package and the previous ones you choose to retain; `iosparkle publish` keeps two by default (`--keep-builds <N>`) and removes older `app-<digits>.ipa` files. Files with other names in the directory are left untouched.

### Publishing atomically

The Feed must never point at a file that is not there yet. Either write the Channel to a staging directory and switch it in with a single rename, or upload in this order: the package, then `manifest.plist`, then `feed.json`, then `index.html`. `iosparkle publish` stages and renames for both `--out` and `--ssh`.

### Addressing

The Host App is configured with the Channel URL, with or without a trailing slash, and reads `<channel URL>feed.json`. Keep the URL free of query strings and fragments; a secret path prefix is the supported way to make a Channel hard to find (see [Self-Hosting & Private Channels](self-hosting.md)).

## `feed.json` v1

The minimal Feed carries four required fields:

```json
{
  "schemaVersion": 1,
  "bundleId": "com.example.myapp.dev",
  "version": "1.4.0",
  "build": 118
}
```

Every optional field, plus an unknown key that readers ignore:

```json
{
  "schemaVersion": 1,
  "bundleId": "com.example.myapp.dev",
  "version": "1.4.0",
  "build": 118,
  "manifestURL": "https://ota.example.com/my-app-dev/manifest.plist",
  "publishedAt": "2026-12-05T09:30:00.125Z",
  "commit": "79806e2e",
  "minimumOSVersion": "17.0",
  "releaseNotes": "Plain-text summary",
  "sizeBytes": 25629710,
  "sha256": "350930f5c6afe8738841fef0da90d968309033bcb5fb7e584bb96620e5df5a48",
  "futureHint": "ignored"
}
```

### Fields

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `schemaVersion` | integer | **Yes** | `1`. A reader that sees a larger number ignores the Feed instead of failing: it is written for a newer protocol. |
| `bundleId` | string | **Yes** | The package's `CFBundleIdentifier`. A Host App ignores a Feed whose `bundleId` is not its own, which keeps two apps or variants from crossing updates. |
| `version` | string | **Yes** | The package's `CFBundleShortVersionString`, shown to the user. Never compared. |
| `build` | integer | **Yes** | The package's `CFBundleVersion`, `>= 1`. An update exists exactly when `build` is greater than the running app's build number. |
| `manifestURL` | string | No | Absolute `https` URL of the manifest. Omit it for a static Channel, where `manifest.plist` sits beside the Feed. A private Channel sets it to a short-lived link. |
| `publishedAt` | string | No | ISO 8601 timestamp, such as `2026-12-05T09:30:00Z`. |
| `commit` | string | No | Source revision. The first seven characters are shown. |
| `minimumOSVersion` | string | No | Dot-separated version, such as `17.0`. Devices below it are never offered the update. |
| `releaseNotes` | string | No | Plain text. Markup is never rendered. |
| `sizeBytes` | integer | No | Package size in bytes. |
| `sha256` | string | No | 64 lowercase hex characters: the SHA-256 of the whole package. |

### Rules that are easy to get wrong

- **Integers are integer literals.** `118` is accepted; `118.0`, `118e0`, and `"118"` are rejected by both the Host App and the `iosparkle` tool.
- **An optional field is absent or present with the right type.** `null` is not a valid value for any field; `"commit": null` makes the Feed malformed.
- `manifestURL` must be `https` with a host. `http://` is malformed, as is a relative path.
- `sha256` is lowercase. Uppercase hex is malformed.
- `publishedAt` is `YYYY-MM-DDThh:mm:ss`, an optional fraction, then `Z` or `±hh:mm`.
- `minimumOSVersion` must be dot-separated integers. Anything else, such as `17..0`, makes the build uninstallable.
- Unknown keys anywhere are ignored, so later minor versions can add fields without breaking existing readers.

A Feed that breaks one of the format rules is not an error the user sees: the Host App ignores it and keeps whatever it knew before. `iosparkle next-build` and `iosparkle verify` exit non-zero instead, which is why they belong in a publishing pipeline.

## `manifest.plist`

The manifest is the document Apple's wireless installation format requires. This is the complete structure the `iosparkle` tool generates:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>items</key>
  <array>
    <dict>
      <key>assets</key>
      <array>
        <dict>
          <key>kind</key><string>software-package</string>
          <key>url</key><string>https://ota.example.com/my-app-dev/app-118.ipa</string>
        </dict>
      </array>
      <key>metadata</key>
      <dict>
        <key>bundle-identifier</key><string>com.example.myapp.dev</string>
        <key>bundle-version</key><string>1.4.0</string>
        <key>kind</key><string>software</string>
        <key>platform-identifier</key><string>com.apple.platform.iphoneos</string>
        <key>title</key><string>MyApp Dev</string>
      </dict>
    </dict>
  </array>
</dict>
</plist>
```

| Key | Value |
| --- | --- |
| `items[0].assets[0].kind` | Always `software-package`. |
| `items[0].assets[0].url` | Absolute `https` URL of the package. |
| `items[0].metadata.bundle-identifier` | Must equal `bundleId` in the Feed. iOS matches the installed app by it, which is what lets an update replace the app in place and keep its data. |
| `items[0].metadata.bundle-version` | The Feed's `version`. |
| `items[0].metadata.kind` | Always `software`. |
| `items[0].metadata.platform-identifier` | Always `com.apple.platform.iphoneos`. |
| `items[0].metadata.title` | Shown in the iOS install dialog. |

Values are XML text, so they are entity-escaped: `&` → `&amp;`, `<` → `&lt;`, `>` → `&gt;`, `"` → `&quot;`, `'` → `&apos;`, with `&` done first. This is the only escaping applied to the package URL inside the manifest; it is not URL-encoded there.

### Why there is no `md5` or `sha256` here

- `md5` is deprecated by Apple and ignored whenever a SHA-256 value is present.
- A single-value `sha256` on the asset entered Apple's manifest specification only with iOS 26.0; iOS 16 through iOS 25 cannot be relied on to honor it.
- Neither is what protects the device. After unpacking, iOS verifies the package's code signature and provisioning profile regardless of what the manifest says.

The publisher's integrity check lives in the Feed instead: `sha256` and `sizeBytes` describe the whole package, and `iosparkle verify` compares them with what the Channel actually serves.

## The install link

The Host App starts an installation by opening this URL:

```text
itms-services://?action=download-manifest&url=<encoded manifest URL>
```

iOS decodes the `url` parameter once and fetches the result. The encoded value is therefore the complete manifest URL with **every byte percent-encoded except the RFC 3986 unreserved characters** `A-Z a-z 0-9 - . _ ~`.

Because the whole URL is encoded this way, anything the manifest URL had already encoded is encoded a second time — hence *double encoding*. A SigV4 credential's `%2F` becomes `%252F`; `&` becomes `%26`; `+` becomes `%2B`; `=` becomes `%3D`. One decode recovers the original URL byte for byte, and the signature or token in it survives.

The alternative fails in a way that is easy to miss. If `&`, `=`, and `+` are left bare — which is what Swift's `CharacterSet.urlQueryAllowed` does, because it describes a whole query string and not one value — the outer parser ends the `url` parameter at the first `&`. iOS requests a truncated manifest URL and the origin answers `403`.

### Test vectors

These are the reference vectors; every encoder must reproduce them exactly.

```json
[
  {
    "manifestURL": "https://ota.example.com/my-app-dev/manifest.plist",
    "encodedURL": "https%3A%2F%2Fota.example.com%2Fmy-app-dev%2Fmanifest.plist",
    "itmsURL": "itms-services://?action=download-manifest&url=https%3A%2F%2Fota.example.com%2Fmy-app-dev%2Fmanifest.plist"
  },
  {
    "manifestURL": "https://s3.ota.example.com/channels/my%20app/manifest.plist?X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20261205%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=deadbeef&token=a+b=c%2Fd",
    "encodedURL": "https%3A%2F%2Fs3.ota.example.com%2Fchannels%2Fmy%2520app%2Fmanifest.plist%3FX-Amz-Credential%3DAKIAIOSFODNN7EXAMPLE%252F20261205%252Fus-east-1%252Fs3%252Faws4_request%26X-Amz-Signature%3Ddeadbeef%26token%3Da%2Bb%3Dc%252Fd",
    "itmsURL": "itms-services://?action=download-manifest&url=https%3A%2F%2Fs3.ota.example.com%2Fchannels%2Fmy%2520app%2Fmanifest.plist%3FX-Amz-Credential%3DAKIAIOSFODNN7EXAMPLE%252F20261205%252Fus-east-1%252Fs3%252Faws4_request%26X-Amz-Signature%3Ddeadbeef%26token%3Da%2Bb%3Dc%252Fd"
  },
  {
    "manifestURL": "https://r2.ota.example.com/channels/my app/manifest.plist?X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20261205%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=deadbeef&token=a+b=c%2Fd&label=release%20candidate",
    "encodedURL": "https%3A%2F%2Fr2.ota.example.com%2Fchannels%2Fmy%20app%2Fmanifest.plist%3FX-Amz-Credential%3DAKIAIOSFODNN7EXAMPLE%252F20261205%252Fus-east-1%252Fs3%252Faws4_request%26X-Amz-Signature%3Ddeadbeef%26token%3Da%2Bb%3Dc%252Fd%26label%3Drelease%2520candidate",
    "itmsURL": "itms-services://?action=download-manifest&url=https%3A%2F%2Fr2.ota.example.com%2Fchannels%2Fmy%20app%2Fmanifest.plist%3FX-Amz-Credential%3DAKIAIOSFODNN7EXAMPLE%252F20261205%252Fus-east-1%252Fs3%252Faws4_request%26X-Amz-Signature%3Ddeadbeef%26token%3Da%2Bb%3Dc%252Fd%26label%3Drelease%2520candidate"
  },
  {
    "manifestURL": "https://ota.example.com/Az09-._~/café/清單.plist?extras=!$'()*+#preview",
    "encodedURL": "https%3A%2F%2Fota.example.com%2FAz09-._~%2Fcafe%CC%81%2F%E6%B8%85%E5%96%AE.plist%3Fextras%3D%21%24%27%28%29%2A%2B%23preview",
    "itmsURL": "itms-services://?action=download-manifest&url=https%3A%2F%2Fota.example.com%2FAz09-._~%2Fcafe%CC%81%2F%E6%B8%85%E5%96%AE.plist%3Fextras%3D%21%24%27%28%29%2A%2B%23preview"
  }
]
```

### Reference implementations

Swift — byte-exact, and the algorithm iOSparkle itself uses:

```swift
import Foundation

/// Percent-encodes every UTF-8 byte except the RFC 3986 `unreserved` set.
func percentEncode(_ value: String) -> String {
    let hex = Array("0123456789ABCDEF".utf8)
    var encoded: [UInt8] = []
    encoded.reserveCapacity(value.utf8.count)
    for byte in value.utf8 {
        switch byte {
        case 0x41...0x5A, 0x61...0x7A, 0x30...0x39, 0x2D, 0x2E, 0x5F, 0x7E:  // A-Z a-z 0-9 - . _ ~
            encoded.append(byte)
        default:
            encoded.append(0x25)  // %
            encoded.append(hex[Int(byte >> 4)])
            encoded.append(hex[Int(byte & 0x0F)])
        }
    }
    return String(decoding: encoded, as: UTF8.self)
}

func installURL(for manifestURL: String) -> String {
    "itms-services://?action=download-manifest&url=\(percentEncode(manifestURL))"
}
```

Python:

```python
from urllib.parse import quote

def percent_encode(value: str) -> str:
    """Percent-encode every UTF-8 byte except RFC 3986 unreserved characters."""
    return quote(value, safe="")  # the default safe="/" would leave slashes bare

def install_url(manifest_url: str) -> str:
    return f"itms-services://?action=download-manifest&url={percent_encode(manifest_url)}"
```

JavaScript and TypeScript:

```ts
/** Percent-encode every UTF-8 byte except RFC 3986 unreserved characters. */
function percentEncode(value: string): string {
  return encodeURIComponent(value).replace(/[!'()*]/g, (c) =>
    "%" + c.charCodeAt(0).toString(16).toUpperCase()
  );
}

function installURL(manifestURL: string): string {
  return `itms-services://?action=download-manifest&url=${percentEncode(manifestURL)}`;
}
```

POSIX shell, using only `printf`, `od`, `tr`, and `awk`:

```sh
# POSIX sh. percent_encode "<manifest url>" prints the encoded value.
percent_encode() {
  printf '%s' "$1" \
    | LC_ALL=C od -An -v -tx1 \
    | LC_ALL=C tr -s ' \n' '\n\n' \
    | LC_ALL=C awk 'NF == 0 { next }
      {
        h = tolower($1) ""              # compare as text, not as a number
        if ((h >= "30" && h <= "39") || (h >= "41" && h <= "5a") || (h >= "61" && h <= "7a") ||
            h == "2d" || h == "2e" || h == "5f" || h == "7e") {
          n = index("0123456789abcdef", substr(h, 1, 1)) - 1
          n = n * 16 + index("0123456789abcdef", substr(h, 2, 1)) - 1
          printf "%c", n
        } else {
          printf "%%%s", toupper(h)
        }
      }'
}

install_url() {
  printf 'itms-services://?action=download-manifest&url=%s\n' "$(percent_encode "$1")"
}
```

## `index.html`

Safari installs an app only through the `itms-services://` link, so the landing page exists to offer one. It shows the title, version, bundle ID, and release notes, and carries an inline QR code of the Channel URL so a device can open it with the Camera app. Inside the HTML, the link's literal `&` before `url=` is written as `&amp;`:

```html
<a href="itms-services://?action=download-manifest&amp;url=https%3A%2F%2Fota.example.com%2Fmy-app-dev%2Fmanifest.plist">Install</a>
```

## What the origin must send

The files are static, but a few response headers are part of the contract. The system installer — not the Host App — fetches the manifest and the package, with no headers of its own and no certificate exceptions.

| File | `Content-Type` | `Cache-Control` | Also required |
| --- | --- | --- | --- |
| `feed.json` | `application/json; charset=utf-8` | `no-store` | — |
| `manifest.plist` | `text/xml` | `no-store` | Serve with `200`; do not redirect. |
| `app-<build>.ipa` | `application/octet-stream` | `public, max-age=31536000, immutable` | Exact `Content-Length`, `Accept-Ranges: bytes` with `206` responses, and no dynamic compression. |
| `index.html` | `text/html; charset=utf-8` | `no-cache` | — |

Everything is HTTPS with a publicly trusted certificate. [Self-Hosting & Private Channels](self-hosting.md) explains why each header matters, how to configure common hosts, and how to run a private Channel.

## Checking a published Channel

`iosparkle verify` reads the Feed, fetches the manifest it points to, checks that the manifest agrees with the Feed, then streams the package and compares its size and SHA-256:

```sh
iosparkle verify --channel-url https://ota.example.com/my-app-dev --ipa MyAppDev.ipa
```

It uses `GET` only, so it works on presigned package URLs as well as static ones. See [CLI & App Store Audit](cli-and-audit.md) for every option.
