xcode 如何修复“是动态库,未添加到静态库”警告?

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

How to fix "is a dynamic library, not added to the static library" warning?

xcodecocos2d-iphonestatic-librariescocos2d-iphone-2.x

提问by Kaizer Sozay

I just upgraded to Xcode 5.1, and all of a sudden there is a new warning:

我刚刚升级到Xcode 5.1,突然出现一个新警告:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool:文件:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1。 sdk/usr/lib/libz.dylib 是动态库,没有加入静态库

The target which generates this warning is the cocos2d-iphone v2 static library (rather than use cocos2d templates, I create a static library). To create the static library all I did was add the cocos2d project to my workspace, have my project link to the libraries that cocos2d links to, and thats it. This all worked fine prior to this update, but now there is a warning.

生成此警告的目标是 cocos2d-iphone v2 静态库(我创建了一个静态库,而不是使用 cocos2d 模板)。要创建静态库,我所做的就是将 cocos2d 项目添加到我的工作区,将我的项目链接到 cocos2d 链接到的库,仅此而已。在此更新之前,这一切正常,但现在出现警告。

How do I fix this ? I do not want to mess with the cocos2d project, because there are some projects in which I use the cocos2d template and not the static library.

我该如何解决 ?我不想弄乱 cocos2d 项目,因为有些项目中我使用了 cocos2d 模板而不是静态库。

回答by LearnCocos2D

Static library targets can not link against dylibs. Previously this was simply ignored. You need to remove said dylib from the static library target and, if necessary, add it to each target that is building the actual app.

静态库目标无法链接 dylib。以前,这被简单地忽略了。您需要从静态库目标中删除所述 dylib,并在必要时将其添加到正在构建实际应用程序的每个目标中。

Look into the Link Binary with Libraries Build Phase. Knowing cocos2d there's probably an Other Linker Flag "-lz" that you need to remove from Build Settings of the cocos2d target.

使用库构建阶段查看链接二进制文件。知道 cocos2d,您可能需要从 cocos2d 目标的构建设置中删除其他链接器标志“-lz”。