Upload dSYMs for iOS

CLI version requirement

The upload script in posthog-ios 4.2.4 and later uploads with hog, PostHog's CLI. posthog-ios 4.x installs with Swift Package Manager. If your builds upload with PostHog's previous CLI (posthog-cli), follow the migration guide.

  1. Install hog

    Required

    Install hog, PostHog's CLI:

    curl -fsSL https://posthog.com/install.sh | sh

    In GitHub Actions, install hog with the PostHog/setup-hog action:

    YAML
    - uses: PostHog/setup-hog@v1

    The upload script looks for hog on PATH, in ~/.local/bin, and in npm's global and project folders. To use a hog in another folder, set HOG_INSTALL_DIR to that folder.

  2. Authenticate

    Required

    Log in to PostHog. This opens your browser, where you approve the login:

    Terminal
    hog auth login

    hog reads the HOG_* names. If your builds set older names, the migration guide lists each rename.

  3. Configure build settings

    Required

    In Xcode, configure your build settings to generate dSYMs:

    1. Open your project in Xcode
    2. Select your target
    3. Go to Build Settings
    4. Search for Debug Information Format
    5. Make sure Release configurations have DWARF with dSYM File
    Xcode dSYM setting
    Disable User Script Sandboxing

    You must disable User Script Sandboxing for the upload script to work:

    1. In Build Settings, search for User Script Sandboxing(ENABLE_USER_SCRIPT_SANDBOXING)
    2. Set ENABLE_USER_SCRIPT_SANDBOXING to 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 run hog, which are currently not allowed with User Script Sandboxing enabled.

  4. Add build phase script

    Required

    To 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:

    1. In Xcode, select your main app target
    2. Go to Build Phases tab
    3. Click the + button and select New Run Script Phase
    4. Make sure it's set to run last (after "Copy Bundle Resources" or similar)
    5. Add this script:
    Terminal
    ${BUILD_DIR%/Build/*}/SourcePackages/checkouts/posthog-ios/build-tools/upload-symbols.sh
    1. In the Input Files section of the Run Script phase, add:
    $(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Resources/DWARF/$(EXECUTABLE_NAME)

    This makes Xcode wait for the app's dSYM contents before running the upload script.

    Using CocoaPods? posthog-ios 4.x isn't published to CocoaPods, so uploads with hog need Swift Package Manager. Apps that still install posthog-ios 3.x with CocoaPods can only upload with the deprecated posthog-cli. See iOS apps on CocoaPods.

  5. Optional: Include source code context

    Optional

    By default, only debug symbols are uploaded. To include source code snippets in your stack traces (for better debugging context), set the POSTHOG_INCLUDE_SOURCE environment variable:

    1. In the Run Script build phase, click the chevron to expand
    2. Set the environment Variable when calling the upload script:
    Terminal
    POSTHOG_INCLUDE_SOURCE=1 ${BUILD_DIR%/Build/*}/SourcePackages/checkouts/posthog-ios/build-tools/upload-symbols.sh

    Note: This increases upload size and build times. Only enable if you need source code context in PostHog's error tracking UI.

  6. Optional: Skip conflicting uploads

    Optional

    If PostHog already has a dSYM with the same UUID but different content, the upload fails with content_hash_mismatch and stops your build. To skip these conflicting uploads and keep the existing symbols instead, set the POSTHOG_SKIP_ON_CONFLICT environment variable when calling the upload script:

    Terminal
    POSTHOG_SKIP_ON_CONFLICT=1 ${BUILD_DIR%/Build/*}/SourcePackages/checkouts/posthog-ios/build-tools/upload-symbols.sh
  7. Build and verify

    Required

    Build your app in Xcode. The dSYM upload script will automatically run and upload symbols to PostHog.

    Check the build log output for confirmation.

  8. Force a test crash

    Optional

    To verify everything is working end-to-end, force a test crash and confirm it appears in PostHog.

    1. Add a crash trigger button to your app:
    Button("Test Crash") {
    fatalError("PostHog test crash")
    }
    1. 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
    2. Reopen the app from your device or simulator's home screen (not from Xcode).

    3. Tap the Test Crash button. The app will crash. The exception is collected but not yet sent to PostHog.

    4. Reopen the app once more. This triggers the SDK to send the previously collected crash report to PostHog.

    5. Check the error tracking dashboard for your test crash.

    Remove the crash trigger button before shipping to production.

  9. Verify dSYMs upload

    Checkpoint
    Confirm that dSYMs are successfully uploaded to PostHog.Check symbol sets in PostHog

Troubleshooting

Script fails with "error: hog not found"

The script couldn't find hog. Install it using one of these methods:

Terminal
# npm global install
npm install -g hog
# Or Homebrew
brew install posthog/tap/hog
# Or the install script
curl -fsSL https://posthog.com/install.sh | sh

Script fails with "error: hog needs you to act before it can upload"

hog prints this when it has no login. Run hog auth login on the machine. In CI, follow the Authenticate step.

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).

Script fails with "content_hash_mismatch"

This happens when the upload script runs before Xcode finishes generating the dSYM files. Leave Based on dependency analysis enabled and add $(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Resources/DWARF/$(EXECUTABLE_NAME) to the Input Files of the Run Script build phase. This makes Xcode wait for the app's dSYM contents before running the upload script.

Still have questions?

Was this page useful?