Skip to content

Commit c12af86

Browse files
committed
match up script
1 parent 161c795 commit c12af86

File tree

1 file changed

+57
-19
lines changed

1 file changed

+57
-19
lines changed

docs/platforms/apple/guides/ios/size-analysis/insights.mdx

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ sidebar_order: 5250
44
description: See how Size Analysis surfaces trends for your iOS builds.
55
---
66

7-
TODO: ADD SOME PICS
8-
97
Size Analysis Insights point out how opportunities to reduce your iOS app's size. They spot patterns like duplicate files, oversized media, or unneeded assets, and list exactly what to fix along with the estimated size savings.
108

119
## iOS Insights
@@ -40,7 +38,7 @@ Below are a list of available insights for iOS builds, followed by more details
4038
has them) before stripping.
4139
</Alert>
4240

43-
In Xcode, ensure your release configuration sets the `Debug Information Format` build setting to `DWARF with dSYM`.
41+
In Xcode ensure your release configuration sets the `Debug Information Format` build setting to `DWARF with dSYM`.
4442

4543
The `strip` command can then remove the extra information:
4644

@@ -60,21 +58,61 @@ To automate stripping in your project after building, add a Run Script phase tha
6058
#!/bin/bash
6159
set -e
6260

63-
if [ "Release" != "${CONFIGURATION}" ]; then
64-
echo "Skipping symbol stripping for ${CONFIGURATION} build."
65-
exit 0
61+
echo "Starting the symbol stripping process..."
62+
63+
if [ "Release" = "${CONFIGURATION}" ]; then
64+
echo "Configuration is Release."
65+
66+
# Path to the app directory
67+
APP_DIR_PATH="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_FOLDER_PATH}"
68+
echo "App directory path: ${APP_DIR_PATH}"
69+
70+
# Strip main binary
71+
echo "Stripping main binary: ${APP_DIR_PATH}/${EXECUTABLE_NAME}"
72+
strip -rSTx "${APP_DIR_PATH}/${EXECUTABLE_NAME}"
73+
if [ $? -eq 0 ]; then
74+
echo "Successfully stripped main binary."
75+
else
76+
echo "Failed to strip main binary." >&2
77+
fi
78+
79+
# Path to the Frameworks directory
80+
APP_FRAMEWORKS_DIR="${APP_DIR_PATH}/Frameworks"
81+
echo "Frameworks directory path: ${APP_FRAMEWORKS_DIR}"
82+
83+
# Strip symbols from frameworks, if Frameworks/ exists at all
84+
# ... as long as the framework is NOT signed by Apple
85+
if [ -d "${APP_FRAMEWORKS_DIR}" ]; then
86+
echo "Frameworks directory exists. Proceeding to strip symbols from frameworks."
87+
find "${APP_FRAMEWORKS_DIR}" -type f -perm +111 -maxdepth 2 -mindepth 2 -exec bash -c '
88+
codesign -v -R="anchor apple" "{}" &> /dev/null ||
89+
(
90+
echo "Stripping {}" &&
91+
if [ -w "{}" ]; then
92+
strip -rSTx "{}"
93+
if [ $? -eq 0 ]; then
94+
echo "Successfully stripped {}"
95+
else
96+
echo "Failed to strip {}" >&2
97+
fi
98+
else
99+
echo "Warning: No write permission for {}"
100+
fi
101+
)
102+
' \;
103+
if [ $? -eq 0 ]; then
104+
echo "Successfully stripped symbols from frameworks."
105+
else
106+
echo "Failed to strip symbols from some frameworks." >&2
107+
fi
108+
else
109+
echo "Frameworks directory does not exist. Skipping framework stripping."
110+
fi
111+
else
112+
echo "Configuration is not Release. Skipping symbol stripping."
66113
fi
67114

68-
APP_DIR_PATH="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_FOLDER_PATH}"
69-
echo "Stripping main binary: ${APP_DIR_PATH}/${EXECUTABLE_NAME}"
70-
strip -rSTx "${APP_DIR_PATH}/${EXECUTABLE_NAME}"
71-
72-
APP_FRAMEWORKS_DIR="${APP_DIR_PATH}/Frameworks"
73-
if [ -d "${APP_FRAMEWORKS_DIR}" ]; then
74-
find "${APP_FRAMEWORKS_DIR}" -maxdepth 2 -mindepth 2 -type f -perm -111 -exec bash -c '
75-
codesign -v -R="anchor apple" "$1" &> /dev/null || strip -rSTx "$1"
76-
' _ {} \;
77-
fi
115+
echo "Symbol stripping process completed."
78116
```
79117

80118
Because Xcode generates dSYMs from the unstripped binary, list the dSYM as an Input File so the script runs after Xcode finishes generating it:
@@ -192,7 +230,7 @@ optimize_icon() {
192230

193231
### Loose Images
194232

195-
**What it is**: Finds scaled @1x/@2x/@3x images stored outside of asset catalogs. App thinning will not remove these images, even when they are not needed for the user's device.
233+
**What it is**: Finds scaled @1x/@2x/@3x images stored outside of asset catalogs. This prevents app thinning from removing variants not needed for the user's device.
196234

197235
**How to fix**: Move each image set into an asset catalog in Xcode.
198236

@@ -226,11 +264,11 @@ optimize_icon() {
226264

227265
**How to fix**: Start with low-effort cleanup, then automate comment stripping if you still ship large payloads.
228266

229-
#### Option 1: Keep the Format Lean
267+
#### Option 1: Keep the format lean
230268

231269
- Encode localized strings as plain text (`"key" = "value";`), not binary plists. Set **Strings File Output Encoding** (`STRINGS_FILE_OUTPUT_ENCODING`) to **UTF-8** in Xcode.
232270

233-
#### Option 2: Strip Comments Automatically
271+
#### Option 2: Strip comments automatically
234272

235273
String files can have comments that ship with the bundle. They help during translation but take space in production. A typical comment may look like:
236274

0 commit comments

Comments
 (0)