删除 Xcode 中未使用的框架?
随着时间的推移,当您开发应用程序时,您会向其中添加新的库,库需要新的框架才能工作。然后删除库,如果您像我一样,您会忘记删除最初添加的框架。
有没有办法找出我的代码运行需要哪些框架?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只是从 Xcode 的链接阶段删除有问题的框架(或者 xcconfig,如果你在那里定义它们),并根据 ld 的错误重新引入框架。
如果您的目标是多个操作系统版本,那么构建并链接这些 SDK 可能是个好主意,因为事情可能会发生一些变化。
我通常也不会将静态库链接到它们的依赖项,而是将其保留为最终的可执行文件。
该阶段完成后,您可以从 Xcode 项目中删除未链接的框架。
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.
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.
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.
我讨厌挖掘坟墓,但我发现您可以通过在检查器和构建中的目标中取消选中它来轻松测试依赖性。如果没有错误,则不存在依赖性。
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.