删除 Xcode 中未使用的框架?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7847558/
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-14 22:11:29  来源:igfitidea点击:

Removing unused frameworks in Xcode?

objective-cxcodeframeworksxcode-project

提问by Peter Warbo

Over time when you develop an application you add new libraries to it, new frameworks needed for the libraries to work. Then you remove libraries and if you are like me you have forgotten to remove the frameworks that you initially added.

随着时间的推移,当你开发一个应用程序时,你会向它添加新的库,这些库需要新的框架才能工作。然后您删除库,如果您像我一样忘记删除您最初添加的框架。

Is there a way to find out what frameworks are needed for my code to function?

有没有办法找出我的代码运行需要哪些框架?

采纳答案by justin

I just delete the questionable frameworks from the link phase in Xcode (or the xcconfig, if you define them there) and reintroduce the frameworks based on ld's errors.

我只是从 Xcode 的链接阶段(或 xcconfig,如果你在那里定义它们)中删除有问题的框架,并根据 ld 的错误重新引入框架。

If you are targeting multiple OS versions, it may be a good idea to also build and link against those SDKs since things can move around a bit.

如果您的目标是多个操作系统版本,那么构建和链接这些 SDK 可能是一个好主意,因为事情可能会发生一些变化。

I also do not typically link static libraries to their dependencies, reserving that for the final executable.

我通常也不将静态库链接到它们的依赖项,将其保留给最终的可执行文件。

Once that phase is complete, you can remove the frameworks you do not link from your Xcode project.

该阶段完成后,您可以从 Xcode 项目中删除您未链接的框架。

回答by Its_Cory

I hate to grave dig, but I had found that you can easily test dependency by unchecking it from your target in Inspector and building. If there are no errors, there is no dependency.

我讨厌挖坟,但我发现您可以通过在 Inspector 和构建中从目标中取消选中它来轻松测试依赖项。如果没有错误,则没有依赖性。