Xcode 中的“剥离 Swift 符号”实际上是做什么的?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46077700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:13:08  来源:igfitidea点击:

What does "strip Swift symbols" in Xcode actually do?

iosxcodeapp-thinning

提问by atineoSE

When exporting an archive of a project containing Swift, we get the option to "strip Swift symbols". I haven't seen any difference in app size though in a project with just one dummy Swift file, thus a perfect case for maximum stripping.

导出包含 Swift 的项目的存档时,我们可以选择“剥离 Swift 符号”。尽管在一个只有一个虚拟 Swift 文件的项目中,我没有看到应用程序大小的任何差异,因此是最大剥离的完美案例。

What does this do exactly and how does it affect the final app size (.ipa)?

这究竟是做什么的,它如何影响最终的应用程序大小 (.ipa)?

enter image description here

在此处输入图片说明

P.S: as seen in Xcode 9 beta 6

PS:如 Xcode 9 beta 6 所示

UPDATE: actually I can observe a slight ipa size reduction (3.4 MB uncompressed) when looking at specific devices variants (not for universal variant though)

更新:实际上,在查看特定设备变体(但不适用于通用变体)时,我可以观察到 ipa 大小略有减少(未压缩 3.4 MB)

采纳答案by Manuel

According to the Xcode docs:

根据Xcode 文档

The new Strip Swift Symbols (STRIP_SWIFT_SYMBOLS) build setting is enabled by default. It adjusts the level of symbol stripping so that when the linked product of the build is stripped, all Swift symbols are removed. This significantly reduces the size of Swift frameworks. If the lack of Swift symbols causes problems, such as when using dladdr(), this setting can be disabled. To view the exported symbols from file that has been stripped, use xcrun dyldinfo -exportinstead of nm. (31306055)

STRIP_SWIFT_SYMBOLS默认情况下启用新的 Strip Swift Symbols ( ) 构建设置。它调整符号剥离的级别,以便当构建的链接产品被剥离时,所有 Swift 符号都将被删除。这显着减少了 Swift 框架的大小。如果缺少 Swift 符号导致问题,例如在使用 时 dladdr(),可以禁用此设置。要从已剥离的文件中查看导出的符号,请使用xcrun dyldinfo -export代替nm。(31306055)