如何从 App Store 发布版本中删除某些框架和代码? [英] How to remove certain frameworks and code from an App Store release build?

查看:36
本文介绍了如何从 App Store 发布版本中删除某些框架和代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 TestFlight SDK 和其他调试框架的应用,我想为 App Store 发布版本自动删除这些框架.

I have an app that uses TestFlight SDK and other debugging frameworks which I want to remove automatically for App Store release builds.

我创建了一个新的App Store"构建配置,但是我如何教 Xcode 我想要包含在这个构建中的框架?以及如何使使用这些框架的代码有条件,以便将其排除在 App Store 发布版本之外?

I created a new "App Store" build configuration, but how can I teach Xcode which frameworks I want to be included with this build? And how can I make the code that uses these frameworks conditional so it is excluded from the App Store release build?

推荐答案

您有三个对您有利的流程组件,用于删除无关代码.

You have three components of the process that work in your favor, to remove extraneous code.

首先,你有预处理器.如果你用 #if DEBUG 语句包装你的 TestFlight 导入和代码,那么你会没事的.#if 语句的设计目的是让预处理器去除您不需要的额外语句.它不会进入编译器.

First, you have the preprocessor. If you wrap your TestFlight import and code with #if DEBUG statements, then you will be fine. The #if statement is designed so that the preprocessor will strip out extra statements that you don't need. It won't make it to the compiler.

其次,编译器为您服务.编译器很聪明地从发布版本中去除死代码.如果你写代码不使用它,它不会成为最终的二进制文件,即使它通过了预处理器.

Second, the compiler is there for you. The compiler is smart about stripping dead code from release builds. If you write code and don't use it, it won't make it into the final binary, even if it passes the preprocessor.

第三,如果您真的担心将这些框架纳入您的发布版本,您可以在 Xcode 中创建一个额外的目标,并更改该目标的链接器选项.这不是必需的,但如果您愿意,可以选择.这是最接近您的显式排除".

Third, if you're really concerned about those frameworks making it into your release builds, you can make an extra target in Xcode, and change the linker options for that target. This isn't necessary, but the option is there for you if you'd like. This is the closest to your "explicit exclusion".

老实说,相信你的编译器和链接器,除非他们给你理由不这样做.

Honestly, though, trust your compiler and linker, unless they give you reason not to.

这篇关于如何从 App Store 发布版本中删除某些框架和代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆