iOS链接二进制文件,仅用于调试库 [英] iOS Link Binary with library for debug only

查看:116
本文介绍了iOS链接二进制文件,仅用于调试库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为项目设置不同的配置时遇到了一些问题。我有两个版本的相同静态库。一个启用了日志记录,另一个没有启用。

I have a bit of a problem with setting different configuration for my project. I have two versions of the same static library. One has logging enabled, the other doesn't.

我正在使用两个不同的xcconfig文件进行调试与发布。在这些文件中,我指定了静态库的两个变体的库和头搜索路径。到现在为止还挺好。

I am using two different xcconfig files for Debug vs. Release. In these files I specify the library and header search paths for the two variants of the static lib. So far so good.

然而,在我的构建设置中,我看不到有条件地链接实际库的方法。即使用Debug的调试版本和Release版本。

However, in my build settings I can't see a way to conditionally link the actual library. I.e use the debug variant for Debug and the release for Release.

任何想法?

推荐答案

您需要使用Other Linker Flags构建设置链接库,而不是使用标准的Link Binary With Libraries UI。可以根据配置更改构建设置:

You need to link the library using the "Other Linker Flags" build setting, rather than the standard "Link Binary With Libraries" UI. The build setting can be changed depending on the configuration:

单击三角形,您可以为调试/发布提供不同的值。您需要使用 -l <​​/ code>标志。例如,对于 libMyLib.a 的文件名,请使用标志 -lMyLib 。您可能需要编辑库搜索路径以搜索相应的位置。

Click the triangle and you can give different values for Debug/Release. You will need to use the -l flag. For example, for a filename of libMyLib.a use the flag -lMyLib. You may need to edit the "Library Search Paths" to search the appropriate location.

如果调试版和发行版的文件名相同且您不想要要更改它们,将它们分别放入它们自己的 lib / Debug lib / Release 目录中。然后编辑库搜索路径构建设置,添加$ SRCROOT / lib / Debug$ SRCROOT / lib / Release用于适当的配置。

If the filenames for the debug and release version are the same and you don't want to change them, put them into their own lib/Debug and lib/Release directories respectively. Then edit the "Library Search Paths" build setting adding either "$SRCROOT/lib/Debug" or "$SRCROOT/lib/Release" for the appropriate configuration.

这篇关于iOS链接二进制文件,仅用于调试库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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