有什么要设置X code 4工作区在需要的时候建立依赖关系的正确方法是什么? [英] What's the correct way to configure XCode 4 workspaces to build dependencies when needed?

查看:179
本文介绍了有什么要设置X code 4工作区在需要的时候建立依赖关系的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况很简单,有两个兄弟项目工作区:一个主(IOS)的应用程序,并且建立了应用程序使用的几个静态库目标的项目

下面是我如何配置构建:


  • 指出在主应用程序的构建设置到库项目位置的用户头搜索路径(通过源代码树)

  • 在我的应用程序的主要对象的编辑 - >构建阶段 - >链接二进制与图书馆一节,增加了库产品我想使用

  • 在该方案中,勾选查找暗指的依赖

在一个干净的(以及所得到的数据缺失),构建网我的主要项目的构建过程中这个错误:

  LD:库未找到-lChipmunk
铿锵:错误:连接命令,退出code 1(使用-v看看调用)失败
命令/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang失败,退出code 1

果然,如果我看在新创建的导出数据,被发现的唯一对象文件是主要的应用程序,而不是库。对于* .o文件一个wides $ P $垫'发现'没有透露任何有关,所以库不迷路,他们是绝对不会被建造。

补充一些要点:


  • 当我问起这在苹果开发论坛,它已经建议我应该在主要目标的Build Phases->目标相关编辑器中添加明确DEPS。但你只可以在这里添加DEPS到目标中的相同的项目或子项目;在我的情况我有应用程序和库项目,职场兄弟姐妹。

  • 如果我的主构建之前手工打造每库,一切都很好。

更新:

我刚刚想出了一个解决办法,这是所有的DEPS指标纳入添加的主要应用程序的计划的建设的一部分。我曾试图在此之前没有成功,但还没有意识到,我可以拖动列表中的目标,以得到正确的构建顺序。现在建立在发生正确的顺序,既干净后,在上述任何一种库或主应用程序源代码更改后。

我在这里留下问题,因为肯定手动整理出一个建造顺序不应该是必要的。必须有与我如何设置的事情有些不对劲。


解决方案

编辑方案(交换周围构建目标,非/勾选并行化编译和/或查找暗指的依赖),对我来说没有工作。我仍然不得不清理建设项目,在静态库的code修改后。搜索开发论坛,我终于找到这个答案,这创造了奇迹。


  

确认身份和类型检查是显示,选择在应用程序的项目libWhatever.a文件(而不是库)。如果你看到位置:相对于工程[或相对于组],这是你的问题。


  
  

      
  1. 单击相对于项目并将其更改为相对于建设
      产品。

  2.   
  3. 这将改变的链路的类型,但它仍然会
      被打破。

  4.   
  5. 点击查找按钮,找到输出文件。

  6.   

通过的构建阶段添加静态库现有项目的 - > 链接二进制库的自动使得相对于组(如果两者都在同一个兄弟姐妹工作空间)。改变其位置上述方式解决构建依赖问题,在Project Navigator的某文件应该出现在黑色字母(而不是红色)。

My case is simple, a workspace with two sibling projects: one main (iOS) app and a project that builds several static library targets used by the app.

Here's how I have configured the build:

  • pointed a 'user header search path' in the main app's build settings to the library project location (via a source tree)
  • in my app's main target's editor -> build phases -> "Link Binary With Libraries" section, added the library products I want to use.
  • in the scheme, ticked 'Find Implicit Dependencies'

After a clean (and deletion of the derived data), a build nets me this error during the build of the main project:

ld: library not found for -lChipmunk
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1

Sure enough, if I look in the newly-created derived data, the only object files to be found are for the main app, not the libraries. A widespread 'find' for *.o files doesn't reveal anything relevant, so the libraries aren't getting lost, they're definitely not being built.

Some supplementary points:

  • when I've asked about this on the Apple dev forums, it's been suggested that I should add explicit deps in the main target's Build Phases->Target Dependencies editor. But you can only add deps here to targets in the same project or subprojects; in my case I have the app and library projects as workplace siblings.
  • if I build each library manually before the main build, all is fine.

Update:

I've just figured out a workaround, which is to add all the deps' targets into the 'build' part of the main app's scheme. I had tried this before without success, but hadn't realised that I could drag the targets around in the list to get the right build order. Builds now happen in the correct order, both after a clean, and after changes in either library or main app source.

I'm leaving the question here, because manually sorting out a build order surely shouldn't be necessary. There has to be something wrong with how I have things set up.

解决方案

Editing the scheme (swapping around build targets, un-/check "Parallelize Build" and/or "Find Implicit Dependencies") didn't work for me. I still had to clean build the project, after any code change in the static lib. Searching the dev forums, I finally found this answer, which worked wonders.

Make sure the Identity and Type inspector is showing and select the libWhatever.a file in your application's project (not the library). If you see Location: Relative to Project [or Relative to Group], this is your problem.

  1. Click Relative to Project and change it to Relative to Build Products.
  2. This will change the type of the link, but it will still be broken.
  3. Click the locate button and find the output file.

Adding a static lib to an existing project via Build Phases -> Link Binary with Libraries automatically makes it "Relative to Group" (if both are siblings in the same workspace). Changing its location the way described above resolves the build dependency problem and in the project navigator your .a file should appear in black letters (instead of red).

这篇关于有什么要设置X code 4工作区在需要的时候建立依赖关系的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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