Strip symbols for iPhone application

2019-03-19 17:33发布

问题:

What are the settings in Xcode to strip symbols for an iphone application?

I use these settings in Xcode but still see classnames and their methods in the executable using a binary file editor.

Deployment:

1) Deployment Post processing(checked)

2) Strip Debug Symbols During Copy(checked)

3) Strip Linked Product(checked)

4) Use Separate Strip(checked)

Linking:

5) Dead Code Stripping(checked)

GCC 4.0 - Code Generation

6) Generate Debug Symbols(NOT checked)

回答1:

Objective-C class and method information can't be stripped - it is necessary for execution. Best you can do is come up with some kind of obfuscation, if you want.



回答2:

I did it.

I only checked following three settings, other setting is irrelevant.

1) Deployment Postprocessing (checked)

3) Strip Linked Product (checked)

4) Use Separate Strip (checked)

Of course, you need should check "Distribution" version in schema editor.

Then clean!!! and build.

I'v also confirmed that "strip" command is called by Xcode: Show log navigator, select Build .... release, at the bottom, i found progress description:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip /Users/xxx/Library/Developer/Xcode/DerivedData/aaaaa-dytaamkvztdwfreoqteyeijwqdcu/Build/Products/Distribution-iphoneos/aaaaa.app/aaaaa

Finally, I'v checked the result by "nm" command to final product file,

nm -a /Users/xxx/Library/Developer/Xcode/DerivedData/aaaaa-dytaamkvztdwfreoqteyeijwqdcu/Build/Products/Distribution-iphoneos/aaaaa.app/aaaaa

All function name of current app is really stripped. Such as following function name :

000b0a00 t _pj_ioqueue_create

00092ae4 t ___destroy_helper_block_200

00092af8 t ___68-[MyClass myMethod:param2]_block_invoke_21782

Note: objective-C method and property name string are still produced to app file, but that is not symbol name for OS loader, they are just meta data of objective-C class.