Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add strip symbols script #1462

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ let project = Project(name: "Mail",
"MailResources/**/InfoPlist.strings"
],
entitlements: "MailResources/Mail.entitlements",
scripts: [Constants.swiftlintScript],
scripts: [
Constants.swiftlintScript,
Constants.stripSymbolsScript
],
dependencies: [
.target(name: "MailCore"),
.target(name: "MailCoreUI"),
Expand Down
8 changes: 8 additions & 0 deletions Tuist/ProjectDescriptionHelpers/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ public enum Constants {
public static let destinations = Set<Destination>([.iPhone, .iPad, .macCatalyst])

public static let swiftlintScript = TargetScript.post(path: "scripts/lint.sh", name: "Swiftlint")

public static let stripSymbolsScript = TargetScript.post(
path: "scripts/strip_symbols.sh",
name: "Strip Symbols (Release)",
inputPaths: [
"${DWARF_DSYM_FOLDER_PATH}/${EXECUTABLE_NAME}.app.dSYM/Contents/Resources/DWARF/${EXECUTABLE_NAME}"
]
)
}
21 changes: 21 additions & 0 deletions scripts/strip_symbols.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -e

if [ "Release" = "${CONFIGURATION}" ]; then # Only do this for release builds

# Path to the app directory
APP_DIR_PATH="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_FOLDER_PATH}"
# Strip main binary
strip -rSTx "${APP_DIR_PATH}/${EXECUTABLE_NAME}"
# Path to the Frameworks directory
APP_FRAMEWORKS_DIR="${APP_DIR_PATH}/Frameworks"

# Strip symbols from frameworks, if Frameworks/ exists at all
# ... as long as the framework is NOT signed by Apple
if [ -d "${APP_FRAMEWORKS_DIR}" ]
then
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
fi

# Source: https://docs.emergetools.com/docs/strip-binary-symbols
Loading