Xcode:添加项目作为构建依赖项

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

Xcode : Adding a project as a build dependency

xcodexcodebuildbuild-dependencies

提问by Aran Mulholland

Im playing around with the soundcloud api, in its instructions it says to

我在玩soundcloud api,在它的说明中说

  • drag SoundCloudAPI.xcodeproj into your project
  • add it as a build dependency
  • 将 SoundCloudAPI.xcodeproj 拖入您的项目
  • 将其添加为构建依赖项

I can drag the project in pretty easily, but how does one accomplish the next step?

我可以很容易地将项目拖入,但是如何完成下一步?

采纳答案by theChrisKent

To add it as a dependency do the following:

要将其添加为依赖项,请执行以下操作:

  • Highlight the added project in your file explorer within xcode. In the directory browser window to the right it should show a file with a .a extension. There is a checkbox under the target column (target icon), check it.
  • Right-Click on your Target (under the targets item in the file explorer) and choose Get Info
  • On the general tab is a Direct Dependencies section. Hit the plus button
  • Choose the project and click Add Target
  • 在 xcode 的文件资源管理器中突出显示添加的项目。在右侧的目录浏览器窗口中,它应该显示一个扩展名为 .a 的文件。目标列(目标图标)下有一个复选框,选中它。
  • 右键单击您的目标(在文件资源管理器中的目标项下)并选择获取信息
  • 在常规选项卡上是直接依赖项部分。点击加号按钮
  • 选择项目并点击添加目标

回答by theprojectabot

  1. Select your project in the navigator on left.
  2. Open up the drawer in the middle pane and select your target.
  3. Select Build Phases
  4. Target Dependencies is an option at that point.
  1. 在左侧的导航器中选择您的项目。
  2. 打开中间窗格中的抽屉并选择您的目标。
  3. 选择构建阶段
  4. 目标依赖项是此时的一个选项。

回答by chenop

Tough one for a newbie like me - here is a screenshot that describes it.
Xcode 10.2.1

对于像我这样的新手来说很难 - 这是描述它的屏幕截图。
Xcode 10.2.1

enter image description here

在此处输入图片说明

回答by WrightsCS

Under TARGETSin your project, right-click on your project target (should be the same name as your project)and choose GET INFO, then on GENERALtab you will see DIRECT DEPENDENCIES, simply click the [+]and select SoundCloudAPI.

TARGETS您的项目下,右键单击您的项目目标(应该与您的项目名称相同)并选择GET INFO,然后在GENERAL选项卡上您将看到DIRECT DEPENDENCIES,只需单击[+]并选择SoundCloudAPI

回答by Alok

Just close the Project you want to add , then drag and drop the file .

只需关闭要添加的项目,然后拖放文件即可。

回答by yoAlex5

Xcode 10

Xcode 10

  1. drag-n-drop a project into another project - is called cross-project references[About]
  2. add the added project as a build dependency - is called Explicit dependency[About]
  1. 将一个项目拖放到另一个项目中 - 称为cross-project references[关于]
  2. 将添加的项目添加为构建依赖项 - 称为Explicit dependency[About]
//Xcode 10
Build Phases -> Target Dependencies -> + Add items 

//Xcode 11
Build Phases -> Dependencies -> + Add items 

In Choose items to add:dialog you will see only targets from your project and the sub-project

Choose items to add:对话框中,您将只看到项目和子项目中的目标

enter image description here

在此处输入图片说明

回答by Hamsternik

Today I faced with the same problem. As the result of the first run I got next error:

今天我遇到了同样的问题。作为第一次运行的结果,我得到了下一个错误:

Lexical or Preprocessor Issue: 'SDKProjectName*/*SDKProjectName.h' file not found.

词法或预处理器问题:找不到“SDKProjectName*/*SDKProjectName.h”文件。

But before running, I, obviously, added my SDK into the demo project, just drag&drop .xcodeprojfile into my test project's source tree. After that, I moved into Build Phasestab in setting of the main xcodeproj file (of the demo) and added my SDK as target dependency and embed framework into corresponding tabs.

但在运行之前,我显然将我的 SDK 添加到演示项目中,只需将.xcodeproj文件拖放到我的测试项目的源代码树中。之后,我进入主 xcodeproj 文件(演示的)设置中的Build Phases选项卡,并将我的 SDK 添加为目标依赖项并将框架嵌入到相应的选项卡中。

But at the result, I got an error above!

但结果,我得到了上面的错误!

So, the problem was into empty line on the Header Search Pathsoption. I just wrote "../**"as value for this key and project compiled successfully. So, after that, you can add #include <SDKName/SDKName.h>into any project, which includes this SDK.

因此,问题出在“标题搜索路径”选项上的空行中。我刚刚写"../**"了这个键的值,项目编译成功。因此,在此之后,您可以添加#include <SDKName/SDKName.h>到任何包含此 SDK 的项目中。

ps. My test app was created into root SDK folder.

附:我的测试应用程序被创建到根 SDK 文件夹中。