Created
February 9, 2017 21:48
-
-
Save JohannMG/74be010274c20cc24a5b177104f21007 to your computer and use it in GitHub Desktop.
Strip Mantle Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| #HOW TO USE | |
| # Get architectures with | |
| # $ lipo -info SnapsheetSDK | |
| # Run the script in the same dir as the binary (binary name in this case is SnapsheetSDK) | |
| # Run script with archs are parameters | |
| # $ ./strip_symbols.sh SnapsheetSDK armv7 armv7s i386 x86_64 arm64 | |
| # To check if everything works you can search for MTL (the stripped on should not contain any method definitions | |
| # $ nm SnapsheetSDK | grep MTL | |
| # $ nm SnapsheetSDK-mantleStripped | grep MTL | |
| #path to the sdk you want to strip symbols from | |
| SDK="$1" | |
| #ignore first parameter | |
| shift | |
| ARCHS="" | |
| #loop over each architecture within this sdk | |
| for arch in "$@" | |
| do | |
| echo "$arch" | |
| echo | |
| lipo -thin "$arch" "$SDK" -output "$SDK"-"$arch" | |
| mkdir "$SDK-$arch-extracted" | |
| cd "$SDK-$arch-extracted" | |
| ar -x "../$SDK-$arch" | |
| #remove the symbol files you want from this architecture | |
| rm MTLJSONAdapter.o | |
| rm MTLManagedObjectAdapter.o | |
| rm MTLModel+NSCoding.o | |
| rm MTLModel.o | |
| rm MTLReflection.o | |
| rm MTLValueTransformer.o | |
| rm NSArray+MTLManipulationAdditions.o | |
| rm NSDictionary+MTLManipulationAdditions.o | |
| rm NSError+MTLModelException.o | |
| rm NSObject+MTLComparisonAdditions.o | |
| rm NSValueTransformer+MTLInversionAdditions.o | |
| rm NSValueTransformer+MTLPredefinedTransformerAdditions.o | |
| #recompile the symbol files into the architecture binary file | |
| libtool -static *.o -o "../$SDK-$arch" | |
| #add to the array of architecture names | |
| ARCHS="$ARCHS $SDK-$arch" | |
| cd .. | |
| rm -rf $SDK-$arch-extracted | |
| echo $ARCHS | |
| done | |
| echo "Creating Stripped binary" | |
| #re-compile the extracted fat binary | |
| lipo -create $ARCHS -o "$SDK-mantleStripped" | |
| #remove unused binaries | |
| for arch in "$@" | |
| do | |
| rm $SDK-$arch | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment