Is it bad to enable Dead Code Stripping?

*爱你&永不变心* 提交于 2019-12-21 16:48:32

问题


My iOS project uses dlsym to dynamically point to an optional C library. Optional as-in the project can run with our without it, it just adds features.

For background info: Detect and use optional external C library at runtime in Objective-C

The problem is, XCode cleans up libraries that are "not used". Using dlsym means there are no direct references to my 3rd party library and XCode removes it.

I thought I found a solution, in "Other Linker Flags" I added -force_load "$(SRCROOT)/my_external.a" which worked great in the simulator. (-all_load works fine too but seemed overkill to me).

The problem is when I moved to a real device, this workaround failed and the library is not loaded (same thing with -all_load).

The only thing that worked was to disable in XCode the feature called Dead Code Stripping.

Question is: is it really bad to disable or recommend my customers to disable this feature? If so, is there a better alternative?

来源:https://stackoverflow.com/questions/23405186/is-it-bad-to-enable-dead-code-stripping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!