Strip Binary Symbols (iOS)


Stripping symbols may cause issues with crash symbolication

Binary symbols are used to symbolicate crash reports. Stripping symbols is only recommended if you are uploading DSYMs to a crash reporter.

Swift binaries include large amounts of symbols in a segment of the binary used by the dynamic linker. These are generally not needed in production builds. If you build your app with bitcode these symbols will automatically be stripped out. However, Xcode 14 deprecated bitcode by default and Apple will remove the ability to build with bitcode in a future Xcode release. Here's the command to strip symbols for a particular binary:

strip -rSTx AppBinary -o AppBinaryStripped

The T flag tells strip to remove Swift symbols, the other flags remove debugging and local symbols. Symbol stripping can be done automatically by adding a custom "Run Script" build phase at the very end of building.

Here is a sample script that may require adjustments for your particular project.

set -e

# if [ "Release" = "${CONFIGURATION}" ]; then # Only do this for release builds
    # Path to the app directory
    # Strip main binary
    strip -rSTx "${APP_DIR_PATH}/${EXECUTABLE_NAME}"
    # Path to the Frameworks directory
    # Strip symbols from frameworks, if Frameworks/ exists at all
    # ... as long as the framework is NOT signed by Apple
    if [ -d "${APP_FRAMEWORKS_DIR}" ]
        find "${APP_FRAMEWORKS_DIR}" -type f -perm +111 -maxdepth 2 -mindepth 2 -exec bash -c 'codesign -v -R="anchor apple" "{}" &> /dev/null || (echo "{}" && strip -rSTx "{}")' \;
# fi

Important: Because of Xcode build process optimizations, it may execute the script before the dSYMs are actually generated resulting in dSYMs based on the stripped binary and it might be missing some symbols. To help Xcode execute the script after the dSYMs are generated, add ${DWARF_DSYM_FOLDER_PATH}/${EXECUTABLE_NAME}.app.dSYM/Contents/Resources/DWARF/${EXECUTABLE_NAME} as an Input File: