integration-swift — Claude Code skill: what it does, how to install
integration-swift guides PostHog analytics integration into Swift applications across iOS and macOS targets.
MIT 108 installs ★ 80 updated 2026-10-24
npx skills add PostHog/skills --skill integration-swift -a claude-codeWhat integration-swift does
The skill directs your coding agent through adding PostHog analytics to Swift codebases. Its workflow follows a clear four-step process from initial setup to review and completion. PostHog credentials stay out of source files: the setup reads POSTHOG_PROJECT_TOKEN and POSTHOG_HOST directly from scheme environment variables using a dedicated PostHogEnv enum.
When wiring Swift Package Manager into project.pbxproj, the agent creates separate objects with distinct UUIDs for the build file, product dependency, and remote package reference. The package references the latest release rather than a frozen build number. For macOS targets running App Sandbox, network access requires setting ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES without disabling the sandbox itself.
What it helps with
- integrate PostHog SDK into iOS or macOS Swift projects via SPM
- track user identity during login and signup flows
- forward session and distinct IDs to backend services via HTTP headers
- capture runtime errors around sensitive flows and network boundaries
Example prompts for the agent
- Integrate PostHog analytics into my Swift iOS project
- Set up user identification for signup and signin flows with PostHog
- Configure error tracking around our API boundary in Swift
How to install integration-swift
1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-swift -a claude-code2Manually: put the files in place
~/.claude/skills/integration-swift/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/integration-swift/
1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-swift -a codex2Manually: put the files in place
.agents/skills/integration-swift/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-swift -a cursor2Manually: put the files in place
.cursor/skills/integration-swift/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install PostHog/skills skills/posthog/all/skills/integration-swift2Manually: put the files in place
.github/skills/integration-swift/SKILL.md1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-swift -a gemini-cli2Platform CLI
gemini skills install https://github.com/PostHog/skills --path skills/posthog/all/skills/integration-swiftManually: put the files in place
.devin/skills/integration-swift/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-swift -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about integration-swift
How to install integration-swift in Claude Code?
Run npx skills add PostHog/skills --skill integration-swift -a claude-code.
What does integration-swift do?
It outlines a sequential procedure to embed PostHog in iOS and macOS projects, configure SPM dependencies in project.pbxproj, and wire environment flags.
How does the skill handle macOS App Sandbox?
It sets ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES in the target build settings so events reach analytics servers without disabling sandbox protection.
Source text
SKILL.md · MIT
--- name: integration-swift description: PostHog integration for Swift iOS and macOS applications metadata: author: PostHog version: 1.9.4 --- # PostHog integration for Swift (iOS/macOS) This skill helps you add PostHog analytics to Swift (iOS/macOS) applications. ## Workflow Follow these steps in order to complete the integration: 1. `basic-integration-1.0-begin.md` - PostHog Setup - Begin ← **Start here** 2. `basic-integration-1.1-edit.md` - PostHog Setup - Edit 3. `basic-integration-1.2-revise.md` - PostHog Setup - Revise 4. `basic-integration-1.3-conclude.md` - PostHog Setup - Conclusion ## Reference files - `references/EXAMPLE.md` - Swift (iOS/macOS) example project code - `references/ios.md` - Ios - docs - `references/identify-users.md` - Identify users - docs - `references/basic-integration-1.0-begin.md` - PostHog setup - begin - `references/basic-integration-1.1-edit.md` - PostHog setup - edit - `references/basic-integration-1.2-revise.md` - PostHog setup - revise - `references/basic-integration-1.3-conclude.md` - PostHog setup - conclusion The example project shows the target implementation pattern. Consult the documentation for API details. ## Key principles - **Environment variables**: Always use environment variables for PostHog keys. Never hardcode them. - **Minimal changes**: Add PostHog code alongside existing integrations. Don't replace or restructure existing code. - **Match the example**: Your implementation should follow the example project's patterns as closely as possible. ## Framework guidelines - Read configuration from environment variables via a `PostHogEnv` enum with a `value` computed property that calls `ProcessInfo.processInfo.environment[rawValue]` and `fatalError`s if missing — cases should be `projectToken = "POSTHOG_PROJECT_TOKEN"` and `host = "POSTHOG_HOST"`, set in the Xcode scheme's Run environment variables - When adding SPM dependencies to project.pbxproj, create three distinct objects with unique UUIDs — a `PBXBuildFile` (with `productRef`), an `XCSwiftPackageProductDependency` (with `package` and `productName`), and an `XCRemoteSwiftPackageReference` (with `repositoryURL` and `requirement`). The build file goes in the Frameworks phase `files`, the product dependency goes in the target's `packageProductDependencies`, and the package reference goes in the project's `packageReferences`. - Check the latest release version of posthog-ios at `https://github.com/PostHog/posthog-ios/releases` before setting the `minimumVersion` in the SPM package reference — do not hardcode a stale version - If the project uses App Sandbox (macOS), add `ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES` to the target's build settings so PostHog can reach its servers — do NOT disable the sandbox entirely ## Identifying users Identify users during login and signup events. Refer to the example code and documentation for the correct identify pattern for this framework. If both frontend and backend code exist, pass the client-side session and distinct ID using `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` headers to maintain correlation. ## Error tracking Add PostHog error tracking to relevant files, particularly around critical user flows and API boundaries.
© PostHog · MIT · PostHog/skills