Skip to content

Commit

Permalink
Merge pull request Polidea#23 from tgrf/master
Browse files Browse the repository at this point in the history
obfuscate_project tool compatibility update for Xcode >= 5
  • Loading branch information
tgrf committed Feb 24, 2015
2 parents e945d4a + 96a29a0 commit 4131ef8
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions contrib/obfuscate_project
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ CONFIGURATION=Release
SDK=7.1

# Additional build options
XCTOOL_OPTS=""
XCODEBUILD_OPTS=""
CLASS_GUARD_OPTS="-i IgnoredSymbol -F !ExcludedClass"

# In case of using Xcode >= 6 and SDK >= 8
CLASS_GUARD_OPTS_SDK="--sdk-root /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$SDK.sdk"

####################################################
# BUILD SCRIPT STARTS HERE
####################################################
Expand Down Expand Up @@ -45,14 +48,23 @@ rm -rf build/
[[ -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 \
[[ -n "$WORKSPACE" ]] && XCODEBUILD_OPTS="$XCODEBUILD_OPTS -workspace $WORKSPACE"
[[ -n "$PROJECT" ]] && XCODEBUILD_OPTS="$XCODEBUILD_OPTS -project $PROJECT"
[[ -n "$SCHEME" ]] && XCODEBUILD_OPTS="$XCODEBUILD_OPTS -scheme $SCHEME"
[[ -n "$CONFIGURATION" ]] && XCODEBUILD_OPTS="$XCODEBUILD_OPTS -configuration $CONFIGURATION"

xcodeversion=`xcodebuild -version | grep -oE '^Xcode\s+\d+' | grep -oE '\d+'`
if ((xcodeversion > 5)) || ((SDK >= 8.0))
then
[[ -n "$SDK" ]] && XCODEBUILD_OPTS="$XCODEBUILD_OPTS -sdk iphonesimulator$SDK"
else
[[ -n "$SDK" ]] && XCODEBUILD_OPTS="$XCODEBUILD_OPTS -sdk iphoneos$SDK"
[[ -n "$SDK" ]] && CLASS_GUARD_OPTS_SDK="--sdk-ios $SDK"
fi

echo_and_run xcodebuild $XCODEBUILD_OPTS \
clean build \
-derivedDataPath build
OBJROOT=build/ \
SYMROOT=build/

Expand All @@ -62,17 +74,28 @@ echo_and_run find . -name '*-Prefix.pch' -exec sed -i .bak '1i\
" "{}" \;

# Obfuscate project
for app in build/*/*.app
appsNumber=0;
while read app
do
if ((appsNumber > 0))
then
echo ""
echo ""
echo "You cannot use this tool when there is more than one .app file in products. Otherwise, only the first one will be used for obfuscation."
echo ""
echo ""
exit 1
fi
((appsNumber+=1))

TARGET=$(basename "$app" .app)
echo "Obfuscating $TARGET in $app..."
echo_and_run ios-class-guard \
--sdk-ios "$SDK" \
$CLASS_GUARD_OPTS_SDK \
$CLASS_GUARD_OPTS \
-O "$SYMBOLS_FILE" \
"$app/$TARGET"
break
done
done < <(find build/ -name '*.app')

echo ""
echo ""
Expand Down

0 comments on commit 4131ef8

Please sign in to comment.