简体   繁体   English

在Xcode中构建iOS模拟器时,如何激活死代码剥离?

[英]How do I activate Dead Code Stripping when building for the iOS Simulator in Xcode?

I am using Xcode to build a project that links precompiled object files. 我正在使用Xcode构建一个链接预编译目标文件的项目。 These object files contain some unresolved symbols that are dead-code. 这些目标文件包含一些未解析的死代码符号。 When Xcode builds for the iOS Device, it strips them when linking and everything works smoothly. 当Xcode为iOS设备构建时,它会在链接时删除它们并且一切顺利。 When building for the Simulator, however, it doesn't strip them (-dead_strip is not passed to the linker) even though the option (Dead Code Stripping) is activated in the project configuration. 但是,在为Simulator构建时,即使在项目配置中激活了选项(死代码剥离),它也不会剥离它们(-dead_strip不会传递给链接器)。 If I manually add -dead_strip to the link command on the terminal it builds and runs correctly in the simulator. 如果我手动将-dead_strip添加到终端上的链接命令,它将在模拟器中正确构建并运行。

How do I make Xcode pass -dead_strip as argument to the linker when building for the iOS Simulator? 在构建iOS模拟器时,如何让Xcode将-dead_strip作为参数传递给链接器? I prefer a clean solution, hot a hack. 我更喜欢干净的解决方案,热门的黑客。

Try this steps: 尝试以下步骤:

1) Open XCode and press cmd + 1 1)打开XCode并按cmd + 1

2) Click on your project at left panel -> your target at middle panel 2)点击左侧面板上的项目 - >中间面板上的目标

3) Click on "Build Settings" 3)点击“Build Settings”

4) Find "Other Linker Flags" and add here a your own linker arguments 4)找到“其他链接器标志”并在此添加您自己的链接器参数

Hope will be a useful 希望会有用

From Apple Developer Docs it says that Apple Developer Docs可以看出来

GCC_DEBUGGING_SYMBOLS = full is a prerequisite for DEAD_CODE_STRIPPING. GCC_DEBUGGING_SYMBOLS = full是DEAD_CODE_STRIPPING的先决条件。

Maybe that is set incorrectly ? 也许这设置不正确

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM