Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9590e79

Browse files
author
dannionqiu
committed
add a phase in the patch.sh which is used to modify the mach-o file in order to recreate debug symbols.
restore symbols using tool 'restore-symbol' from "https://github.com/tobefuturer/restore-symbol"
1 parent 139139f commit 9590e79

2 files changed

Lines changed: 38 additions & 4 deletions

File tree

Tools/patch.sh

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,41 @@ echo "TEMP_APP_PATH: $TEMP_APP_PATH"
6363

6464

6565
# ---------------------------------------------------
66-
# 2. Overwrite DummyApp IPA with Target App Contents
66+
# 2 restore symbol and integrate to Mach-O File
67+
68+
# ---------------------------------------------------
69+
# 2.1 try to thin Mach-O File
70+
71+
MACH_O_FILE_NAME=`basename $TEMP_APP_PATH .app`
72+
MACH_O_FILE_PATH=$TEMP_APP_PATH/$MACH_O_FILE_NAME
73+
echo "MACH_O_FILE_PATH: $MACH_O_FILE_PATH"
74+
75+
lipo -thin armv7 $MACH_O_FILE_PATH -o $TEMP_PATH/"$MACH_O_FILE_NAME"_armv7
76+
lipo -thin arm64 $MACH_O_FILE_PATH -o $TEMP_PATH/"$MACH_O_FILE_NAME"_arm64
77+
78+
# ---------------------------------------------------
79+
# 2.2 try to restore symbol by archs
80+
81+
# Sources: https://github.com/tobefuturer/restore-symbol
82+
# restore symbol technique
83+
84+
RESTORE_SYMBOL_TOOL="${SRCROOT}/Tools/restore-symbol"
85+
"$RESTORE_SYMBOL_TOOL" $TEMP_PATH/$"$MACH_O_FILE_NAME"_armv7 -o $TEMP_PATH/$"$MACH_O_FILE_NAME"_armv7_with_symbol
86+
"$RESTORE_SYMBOL_TOOL" $TEMP_PATH/$"$MACH_O_FILE_NAME"_arm64 -o $TEMP_PATH/$"$MACH_O_FILE_NAME"_arm64_with_symbol
87+
88+
# ---------------------------------------------------
89+
# 2.3 reintegrate Mach-O File
90+
91+
lipo -create $TEMP_PATH/"$MACH_O_FILE_NAME"_armv7_with_symbol $TEMP_PATH/"$MACH_O_FILE_NAME"_arm64_with_symbol -o $TEMP_PATH/"$MACH_O_FILE_NAME"_with_symbol
92+
93+
rm -f $MACH_O_FILE_PATH
94+
cp $TEMP_PATH/"$MACH_O_FILE_NAME"_with_symbol $MACH_O_FILE_PATH
95+
96+
97+
98+
99+
# ---------------------------------------------------
100+
# 3. Overwrite DummyApp IPA with Target App Contents
67101

68102
TARGET_APP_PATH="$BUILT_PRODUCTS_DIR/$TARGET_NAME.app"
69103
echo "TARGET_APP_PATH: $TARGET_APP_PATH"
@@ -76,7 +110,7 @@ cp -rf "$TEMP_APP_PATH/" "$TARGET_APP_PATH/"
76110

77111

78112
# ---------------------------------------------------
79-
# 3. Inject the Executable We Wrote and Built (IPAPatch.framework)
113+
# 4. Inject the Executable We Wrote and Built (IPAPatch.framework)
80114

81115
APP_BINARY=`plutil -convert xml1 -o - $TARGET_APP_PATH/Info.plist|grep -A1 Exec|tail -n1|cut -f2 -d\>|cut -f1 -d\<`
82116
OPTOOL="${SRCROOT}/Tools/optool"
@@ -95,7 +129,7 @@ chmod +x "$TARGET_APP_PATH/$APP_BINARY"
95129

96130

97131
# ---------------------------------------------------
98-
# 4. Inject External Frameworks if Exists
132+
# 5. Inject External Frameworks if Exists
99133

100134
TARGET_APP_FRAMEWORKS_PATH="$BUILT_PRODUCTS_DIR/$TARGET_NAME.app/Frameworks"
101135

@@ -125,7 +159,7 @@ done
125159

126160

127161
# ---------------------------------------------------
128-
# 5. Remove Plugins/Watch (AppExtensions), To Simplify the Signing Process
162+
# 6. Remove Plugins/Watch (AppExtensions), To Simplify the Signing Process
129163

130164
rm -rf "$TARGET_APP_PATH/PlugIns" || true
131165
rm -rf "$TARGET_APP_PATH/Watch" || true

Tools/restore-symbol

584 KB
Binary file not shown.

0 commit comments

Comments
 (0)