与iOS项目相关的工作空间,并与一个静态库项目相关 [英] The workspace with the iOS project and related a static library project

查看:59
本文介绍了与iOS项目相关的工作空间,并与一个静态库项目相关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode 4工作区.目前Xcode 4获胜.因此,我的情况:

I am fighting with Xcode 4 workspaces. Currently Xcode 4 wins. Thus, my situation:

我的工作区带有iOS应用程序项目.此工作空间中还依赖于静态库项目iOS应用.

I have the workspace with the iOS app project. There is also static library project iOS app depends on in the this workspace.

我尝试这样配置:

  • 该应用程序项目:
    • 添加到目标的 Build Phases> Link Binary with Library产品(libmystaticlib.a);
    • USER_HEADER_SEARCH_PATHS设置为$(TARGET_BUILD_DIR)/usr/local/include $(DSTROOT)/usr/local/include;
    • the app project:
      • add to target's Build Phases > Link Binary With Library a product (libmystaticlib.a);
      • set USER_HEADER_SEARCH_PATHS to $(TARGET_BUILD_DIR)/usr/local/include $(DSTROOT)/usr/local/include;
      • 将一些头文件添加到目标的 Build Phases> Copy Headers> Public ;
      • SKIP_INSTALL设置为YES.
      • add some header files to target's Build Phases > Copy Headers > Public;
      • set SKIP_INSTALL to YES.

      重要的是:两个项目必须具有名称相同的配置.否则,例如,如果我有针对应用程序的名为 Distribution(Ad Hoc)的配置,以及针对静态库的 Release 的配置,则Xcode无法将应用程序与该库链接.

      And important thing: both projects must have configurations named the same. Otherwise, if I have, e.g., configuration named Distribution (Ad Hoc) for the app and Release for the static library, Xcode can't link the app with the library.

      通过这种配置,可以将结果归档到带有静态库项目中的应用程序和公共标头的存档中.当然,在这种情况下,我无法共享*.ipa. :(

      With this configuration archiving results to an archive with the application and public headers from static library projects. Of course, I am not able to share *.ipa in this case. :(

      我还尝试了另一种配置:

      I have also tried another configuration:

      • Xcode首选项:
        • 设置静态库的源树,例如ADDITIONS_PROJECT;
        • Xcode preferences:
          • set source tree for the static library, e.g, ADDITIONS_PROJECT;
          • 添加到目标的 Build Phases> Link Binary with Library产品(libmystaticlib.a);
          • USER_HEADER_SEARCH_PATHS设置为$(ADDITIONS_PROJECT)/**;
          • add to target's Build Phases > Link Binary With Library a product (libmystaticlib.a);
          • set USER_HEADER_SEARCH_PATHS to $(ADDITIONS_PROJECT)/**;
          • 不要将任何头文件添加到Public!;
          • SKIP_INSTALL设置为YES.
          • don't add any header files to Public!;
          • set SKIP_INSTALL to YES.

          我仍然需要关心两个项目的配置名称.但是结果是我可以成功构建和存档.结果,我得到了存档,可以共享*.ipa.

          I still need to care about configuration names for both projects. But in result I can build and archive successfully. In the result I get archive and I can share *.ipa.

          我不喜欢第二种解决方案,因为在这种情况下,我没有获得Xcode 4工作区的任何真正优势.如果在应用程序项目中添加静态lib项目,则可以添加get的效果相同.因此,我认为我的解决方案出了点问题. 有什么建议可以更好地链接静态库吗?

          I don't like the second solutions, because in this case I don't get any real advantage of the Xcode 4 workspace. The same effect I can add get, if I add the static lib project inside the app project. Therefore, I think something is wrong with my solution. Any suggestion how better to link a static libraries?

          推荐答案

          我还找到了可与build和archive一起使用的解决方案.
          在您的静态库中,将公共头文件夹"路径设置为../../Headers/YourLib
          在您的应用程序配置中,将标题搜索路径"设置为$(BUILT_PRODUCTS_DIR)/../../Headers

          I also found a solution that works with build and with archive.
          In your static library set the Public Headers Folder Path to ../../Headers/YourLib
          In your app config set the Header Search Paths to $(BUILT_PRODUCTS_DIR)/../../Headers

          在您的应用中,您将可以编写#import <YourLib/YourFile.h>

          In your app you will be able to code #import <YourLib/YourFile.h>

          不要忘记静态库中的Skip Install = YES选项.

          Don't forget the Skip Install = YES option in your static lib.

          这篇关于与iOS项目相关的工作空间,并与一个静态库项目相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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