{"schemaVersion":"2.0.0","locale":"en","title":"First analysis","description":"Run three small Swift packages and compare a finding, a control, and an unsupported input. You need the installed CLI and the same terminal with ANALYZER set.","htmlUrl":"https://docs.swift-analyzer.com/get-started/first-analysis/","markdownUrl":"https://docs.swift-analyzer.com/get-started/first-analysis/index.md","productRevision":"524fa07e0ae4153c84ac12ae9eb6559df89ec2be","catalogRevision":"4558458d","docsRevision":"1f17ba58ab08627e0de898f1442067b09e960b48cd5605d6529e9275f8930d68","channel":"pre-prod","maturity":"experimental","access":"owner-provided-checkout","markdown":"# First analysis\n\nRun three small Swift packages and compare a finding, a control, and an unsupported input. You need the [installed CLI](https://docs.swift-analyzer.com/get-started/installation/) and the same terminal with `ANALYZER` set.\n\n## Get the examples\n\n[Download the first-analysis examples](https://docs.swift-analyzer.com/examples/first-analysis.zip). The archive contains authored source only: positive, control, and incomplete packages. It contains no analyzer binary or dependency payload.\n\n```sh\ncurl -fL https://docs.swift-analyzer.com/examples/first-analysis.zip -o first-analysis.zip\nunzip first-analysis.zip -d first-analysis\n```\n\nIn a local preview, use the download link above from your browser. Markdown and JSON retain the candidate's canonical origin; `docs.swift-analyzer.example.invalid` is a placeholder, so replace it with the address serving your preview before using a copied download command. Run `unzip` from the directory containing the downloaded archive.\n\nThe positive package deliberately calls a MainActor assertion from a detached task and holds an NSLock guard across suspension. It is analyzed and compiled; its functions and tests are not executed.\n\n## Run the positive case\n\n`--allow-build` authorizes manifest evaluation, locked dependency retrieval, and a managed indexed build. Use it only for code you intend to build. `--include-stdio-rules` adds two resource conditions; this example has no stdio observations.\n\n```sh\nif \"$ANALYZER\" source-scan \\\n  --package-path ./first-analysis/positive \\\n  --product FirstAnalysis \\\n  --allow-build --include-stdio-rules --format json > positive.json\nthen\n  analysis_status=0\nelse\n  analysis_status=$?\nfi\nprintf 'Analyzer exit: %s\\n' \"$analysis_status\"\n```\n\nOpen `positive.json`. For the recorded profile, the report is `degraded`, exit 3, with 2 admitted sources and 2 findings: required context lost through detachment (V-EXEC-03) and guard held across suspension (V-ASYNC-14). Unknown observations remain. Timing is written to stderr; it is not part of the JSON document.\n\n## Compare the control\n\nThe control removes the detached boundary and releases the guard before `await`. Run the same command with `./first-analysis/control` and `control.json` in place of the positive paths.\n\nIt has 2 admitted sources and 0 findings, but remains `degraded` with exit 3. Some observations are unknown, and some selected conditions have no observations. Zero findings is not proof that the whole program is safe.\n\n## Try the unsupported input\n\nRun the same command with `./first-analysis/incomplete` and `incomplete.json`. Its package uses a resource-processing form unsupported by this snapshot.\n\nThe expected report is `unavailable`, exit 3, 0 admitted sources, and no executed families. Reasons include `unsupported-resource-census:Example` and `unsupported-resource-rule:Example`. This is a refused input, not a clean analysis.\n\n## Compare the observed outcomes\n\n| Package | Report status | Exit | Admitted sources | Findings |\n| --- | --- | --- | --- | --- |\n| positive | degraded | 3 | 2 | 2 |\n| control | degraded | 3 | 2 | 0 |\n| incomplete | unavailable | 3 | 0 | 0 |\n\nThese outcomes were reproduced at product 524fa07e on Apple Swift 6.3.3, macOS arm64, on September 11, 2026. Snapshot identities and timings may differ between runs. The source patterns, coverage states and totals above are the checked expectations. Three examples do not measure portfolio-wide precision or recall.\n\nInspect the complete recorded JSON for the [positive case](https://docs.swift-analyzer.com/examples/positive/observed.json), [control](https://docs.swift-analyzer.com/examples/control/observed.json), and [unsupported input](https://docs.swift-analyzer.com/examples/incomplete/observed.json). These are unchanged CLI outputs from that run; their hashes are recorded in the [public manifest](https://docs.swift-analyzer.com/manifest.json). They are example evidence, not reports for your project. Compare source anchors and coverage before comparing invocation-specific snapshot identifiers.\n\n[Understand the report](https://docs.swift-analyzer.com/guides/results/), then [analyze your own SwiftPM product](https://docs.swift-analyzer.com/guides/swiftpm/).\n","anchors":["first-analysis","get-the-examples","run-the-positive-case","compare-the-control","try-the-unsupported-input","compare-the-observed-outcomes"]}
