简体   繁体   English

构建iOS静态库

[英]Building iOS static library

I have a static library that depends on some of the Apple frameworks though when I include it as a target dependency I still need to add the frameworks it depends on to the application project. 我有一个依赖于某些Apple框架的静态库,尽管当我将其作为目标依赖项包含时,我仍然需要将其依赖的框架添加到应用程序项目中。 Is there some way to setup the project such that the dependencies only have to be specified in the static library target? 有什么方法可以设置项目,以便仅在静态库目标中指定依赖项?

While I'm sure it is possible , you really don't want to do that. 虽然我确定有可能 ,但您确实不想这样做。 I'm not sure you'd be able to get accepted if you did that. 我不确定您是否会被接受。 The static library is linking against dynamic library, the symbols are not included in it like the .m files are. 静态库与动态库链接,符号不像.m文件那样包含在其中。 That is the whole point of dynamic libraries. 这就是动态库的重点。

One solution is to use an xcconfig file. 一种解决方案是使用xcconfig文件。

http://developer.apple.com/library/ios/#recipes/xcode_help-project_editor/Articles/BasingBuildConfigurationsonConfigurationFiles.html http://developer.apple.com/library/ios/#recipes/xcode_help-project_editor/Articles/BasingBuildConfigurationsonConfigurationFiles.html

In this scenario you create a sharable xcconfig file that accompanies the static library. 在这种情况下,您将创建一个静态库随附的可共享xcconfig文件。 Then in your application project you copy the xcconfig file and base your application configuration on it. 然后,在您的应用程序项目中,复制xcconfig文件,并基于该文件进行应用程序配置。

OTHER_LDFLAGS = $(SHARED_LDFLAGS) -framework AssetsLibrary -framework AudioToolbox ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM