Upload dSYMs for iOS
Contents
A minimum CLI version of 0.7.0 is required, but we recommend keeping up with the latest CLI version to ensure you have all of error tracking's features.
- 1
Download CLI
RequiredInstall
posthog-cli: - 2
Authenticate
RequiredTo authenticate the CLI, call the
logincommand. This opens your browser where you select your organization, project, and API scopes to grant:TerminalIf you are using the CLI in a CI/CD environment such as GitHub Actions, you can set environment variables to authenticate:
Environment Variable Description Source POSTHOG_CLI_HOSTThe PostHog host to connect to [default: https://us.posthog.com] Project settings POSTHOG_CLI_PROJECT_IDPostHog project ID Project settings POSTHOG_CLI_API_KEYPersonal API key with error tracking writeandorganization readscopesAPI key settings You can also use the
--hostoption instead of thePOSTHOG_CLI_HOSTenvironment variable to target a different PostHog instance or region. For EU users:Terminal - 3
Configure build settings
RequiredIn Xcode, configure your build settings to generate dSYMs:
- Open your project in Xcode
- Select your target
- Go to Build Settings
- Search for Debug Information Format
- Make sure Release configurations have DWARF with dSYM File

Disable User Script SandboxingYou must disable User Script Sandboxing for the upload script to work:
- In Build Settings, search for User Script Sandboxing(
ENABLE_USER_SCRIPT_SANDBOXING) - Set
ENABLE_USER_SCRIPT_SANDBOXINGto No
Why is this required?
When User Script Sandboxing is enabled, Xcode only allows run scripts to access files explicitly specified in the build phase's Input Files. The dSYM upload script needs to walk directories to locate and read dSYM bundles, and execute
posthog-cliwhich are currently not allowed with User Script Sandboxing enabled. - 4
Add build phase script
RequiredTo symbolicate crash reports, PostHog needs your project's debug symbol (dSYM) files. The following script automatically processes and uploads dSYMs whenever you build your app.
Add a Run Script build phase:
- In Xcode, select your main app target
- Go to Build Phases tab
- Click the + button and select New Run Script Phase
- Make sure it's set to run last (after "Copy Bundle Resources" or similar)
- Add the appropriate script for your package manager:
- 5
Optional: Include source code context
OptionalBy default, only debug symbols are uploaded. To include source code snippets in your stack traces (for better debugging context), set the
POSTHOG_INCLUDE_SOURCEenvironment variable:- In the Run Script build phase, click the chevron to expand
- Set the environment Variable when calling the upload script:
Note: This increases upload size and build times. Only enable if you need source code context in PostHog's error tracking UI.
- 6
Build and verify
RequiredBuild your app in Xcode. The dSYM upload script will automatically run and upload symbols to PostHog.
Check the build log output for confirmation.
- 7
Force a test crash
OptionalTo verify everything is working end-to-end, force a test crash and confirm it appears in PostHog.
- Add a crash trigger button to your app:
Build and run your app in Xcode,
- Make sure the debugger is not attached, since it will intercept the crash and prevent the report from being collected. You can:
- Detach the debugger (click the stop button in Xcode) and run the app directly from the device/simulator home screen
- Or uncheck "Debug executable" in the scheme settings before running
- Make sure the debugger is not attached, since it will intercept the crash and prevent the report from being collected. You can:
Reopen the app from your device or simulator's home screen (not from Xcode).
Tap the Test Crash button. The app will crash. The exception is collected but not yet sent to PostHog.
Reopen the app once more. This triggers the SDK to send the previously collected crash report to PostHog.
Check the error tracking dashboard for your test crash.
Remove the crash trigger button before shipping to production.
Troubleshooting
Script fails with "error: posthog-cli not found"
Install the CLI using one of these methods:
Script fails with permission errors
Ensure ENABLE_USER_SCRIPT_SANDBOXING is set to NO in your build settings.
dSYMs not being generated
Verify that DEBUG_INFORMATION_FORMAT is set to DWARF with dSYM File for the configuration you're building (Debug or Release).