xcode 什么是目标依赖?

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

What is a target dependency?

xcode

提问by Bob Chandelerison

I feel so noob asking this question, but what is a target dependency? I see it all the time in Xcode.

问这个问题我觉得很菜鸟,但什么是目标依赖?我一直在 Xcode 中看到它。

回答by Sherm Pendley

A dependency is another target that must be built before the current target can be. For example, if you have an app target and a framework target, the app target can have the framework target as a dependency, to ensure that the framework is built first. That is, the app target "depends" on the framework.

依赖项是必须在当前目标建立之前构建的另一个目标。例如,如果您有一个 app 目标和一个框架目标,则 app 目标可以将框架目标作为依赖项,以确保首先构建框架。也就是说,应用程序目标“取决于”框架。

回答by yoAlex5

Xcode Dependency[About]is a dependency required to builda selected target.

Xcode Dependency[About]构建选定目标所需的依赖项。

Explicit dependency

显式依赖

Explicitdependency is a source codeaka Non-compiled dependency. Xcode builds all explicit dependenciesbefore the dependent target. Explicit dependencyoverrides implicit dependencywith the same product_name.

Explicit依赖是一个源代码又名Non-compiled dependency。Xcodeexplicit dependencies在依赖目标之前构建所有内容。使用相同的product_nameExplicit dependency覆盖。implicit dependency

Explicit Dependencyis specified in Build Phases -> Target Dependencies.

Explicit Dependency中指定Build Phases -> Target Dependencies

There are multiple ways to specify in Xcode that our target depends on other target's products:

在 Xcode 中有多种方法可以指定我们的目标依赖于其他目标的产品:

  • If the targets are in the same project
    No additional setup
  • If the targets are in different projectsusing cross-project reference[About]
    Specify search path
  • 如果目标在同一个项目中
    无需额外设置
  • 如果目标在不同的项目中使用cross-project reference[About]
    指定搜索路径

Additional notes:

补充说明:

  • Dynamic Framework
    • You should specify General -> Embedded Binaries. If not - on the real device you will get dyld: Library not loaded[About]
    • If you start adding your dependency from General -> Embedded Binariesand select a product that is explicit dependency, Xcode automatically add it into Build Phases -> Target Dependencies
  • Static binary
    • You can fill out only Build Phases -> Target Dependencies
  • Dynamic Framework
    • 您应该指定General -> Embedded Binaries. 如果没有 - 在真实设备上,您将获得dyld: Library not loaded[关于]
    • 如果您开始添加依赖项General -> Embedded Binaries并选择显式依赖项的产品,Xcode 会自动将其添加到Build Phases -> Target Dependencies
  • Static binary
    • 您只能填写 Build Phases -> Target Dependencies

[Implicit dependency]

[隐式依赖]

[Vocabulary]

[词汇]