目标依赖项与带有库的链接二进制文件 [英] Target dependencies vs. Link binary with libraries

查看:33
本文介绍了目标依赖项与带有库的链接二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白这些 Xcode 功能之间的区别.

我正在构建和应用程序 - 但应用程序的功能被抽象为库(因此它们可以作为SDK"单独分发).

所以我有一个库项目和应用项目的工作区.我可以通过执行将二进制文件与库链接"将库项目添加到应用程序项目中.这为我提供了当前工作区中可以链接到的 .a 库项目列表.

我也可以在这里添加框架.

在目标依赖项"中,我只能添加当前项目中的其他目标.

我真正想做的是两者 - 我希望我的应用项目在构建它时构建所有其他库项目.我还想详细说明应用(和其他库)依赖的库.

那么有人可以解释一下区别吗,我正在做的是否是正确的方法?

非常感谢!

解决方案

它说 这里...

<块引用>

  1. 将您的框架产品(位于 Products 文件夹中)拖到应用程序的现有 Link Binary With Libraries 构建阶段目标.这会导致应用链接到您的框架.

还有……

<块引用>

  1. 在检查器窗口的常规"选项卡中,添加您的框架作为应用程序的依赖项.添加此依赖项会导致 Xcode在构建应用程序目标之前先构建框架目标.

您在应用程序目标中建立的构建依赖导致在应用程序之前构建的框架.这个很重要因为它保证您的框架的构建版本将是可用于链接和嵌入到应用程序中.因为此依赖项,您可以设置 Xcode 项目的活动目标到您的应用程序并将其留在那里.

所以看起来你应该同时使用两者.不过似乎是多余的,因为如果您要链接到框架,那么它就是一个依赖项.我想您可能只想链接到一个库而不是先构建它.尽管即使没有将它们添加到依赖项部分,XCode 似乎也构建了链接库.也许这是方案构建设置中查找隐式依赖关系"选项的结果.

I don't understand the difference between these Xcode features.

I'm building and app - but the functionality of the app is being abstracted into libraries (so they can be distributed separately as an "SDK").

So I have a workspace of library projects and the app project. I can add library projects to the app project by doing "link binary with libraries". This gives me a list of .a library projects in the current workspace which I can link to.

I can also add frameworks here.

In the "target dependencies" bit all I can add is other targets in the current project.

What I really want to do is both - I want my app project to build all the other library projects when I build it. I also want to make it verbose what libraries the app (and other libraries) depend on.

So can somebody please explain the difference, and whether what I am doing is the right way to go about it?

Many thanks!

解决方案

It says here...

  1. Drag your framework product (located in the Products folder) to the existing Link Binary With Libraries build phase of your application target. This causes the application to link against your framework.

And...

  1. In the General tab of the inspector window, add your framework as a dependency for the application. Adding this dependency causes Xcode to build the framework target before building the application target.

The build dependency you establish in the application target causes the framework to be built before the application. This is important because it guarantees that a built version of your framework will be available to link against and to embed in the application. Because of this dependency, you can set the active target of your Xcode project to your application and leave it there.

So it seems that you're supposed to use both. Seems redundant though, because if you're linking to a framework then its a dependency. I suppose you might want to only link to a library and not build it first. Although XCode seems to build linked libraries even without them being added to the dependency section. Perhaps that's a result of the "Find Implicit Dependencies" option in a scheme's build settings.

这篇关于目标依赖项与带有库的链接二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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