-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathobfuscate_project
More file actions
executable file
·80 lines (63 loc) · 2.08 KB
/
obfuscate_project
File metadata and controls
executable file
·80 lines (63 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
set -e
# General build options
WORKSPACE=LUAScriptElf.xcworkspace
#PROJECT=LUAScriptElf.xcodeproj
SCHEME=LUAScriptElfUI
CONFIGURATION=Release
SDK=8.0
# Additional build options
XCTOOL_OPTS=""
CLASS_GUARD_OPTS="-i IgnoredSymbol -F !ExcludedClass"
####################################################
# BUILD SCRIPT STARTS HERE
####################################################
# Just in case
echo "WARNING: This will wipe all your not commited changes in your repository"
echo "Press Ctrl-C to Cancel or Enter to proceed."
read
function echo_and_run() {
echo "$@"
"$@"
}
# Jump to directory where obfuscate script is located
pushd $(dirname $0)
# Symbols file path
SYMBOLS_FILE="$PWD/symbols.h"
# Clean current workspace
#echo_and_run git reset --hard
#echo_and_run git clean -fdx
# Just in case: wipe build/
rm -rf build/
# Automatically detect PODS
[[ -f Podfile ]] && [[ ! -f Pods/Manifest.lock ]] && pod install
[[ -f Pods/Pods.xcodeproj/project.pbxproj ]] && CLASS_GUARD_OPTS="$CLASS_GUARD_OPTS -P Pods/Pods.xcodeproj/project.pbxproj"
# Build project to fetch symbols
[[ -n "$WORKSPACE" ]] && XCTOOL_OPTS="$XCTOOL_OPTS -workspace $WORKSPACE"
[[ -n "$PROJECT" ]] && XCTOOL_OPTS="$XCTOOL_OPTS -project $PROJECT"
[[ -n "$SCHEME" ]] && XCTOOL_OPTS="$XCTOOL_OPTS -scheme $SCHEME"
[[ -n "$CONFIGURATION" ]] && XCTOOL_OPTS="$XCTOOL_OPTS -configuration $CONFIGURATION"
[[ -n "$SDK" ]] && XCTOOL_OPTS="$XCTOOL_OPTS -sdk iphoneos$SDK"
echo_and_run xctool $XCTOOL_OPTS \
clean build \
# Insert SYMBOLS_FILE to all .pch found in project
echo_and_run find . -name '*-Prefix.pch' -exec sed -i .bak '1i\
'"#import \"$SYMBOLS_FILE\"
" "{}" \;
# Obfuscate project
for app in LatestBuild/*.app
do
TARGET=$(basename "$app" .app)
echo "Obfuscating $TARGET in $app..."
echo_and_run ios-class-guard \
--sdk-ios "$SDK" \
$CLASS_GUARD_OPTS \
-O "$SYMBOLS_FILE" \
"$app/$TARGET"
break
done
echo ""
echo ""
echo "Congratulations! Obfuscation completed. You can now build, test and archive Your project using Xcode, Xctool or Xcodebuid..."
echo ""
echo ""