What is a target dependency?
Asked Answered
C

2

18

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

Cuirassier answered 22/4, 2011 at 5:54 Comment(0)
F
20

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.

Formulate answered 22/4, 2011 at 6:10 Comment(0)
M
9

Xcode Explicit Dependency

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

Explicit dependency

Explicit dependency is a source code aka Non-compiled dependency. Xcode builds all explicit dependencies before the dependent target. Explicit dependency overrides implicit dependency with the same product_name.

Explicit Dependency is specified in Build Phases -> Target Dependencies.

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

  • If a target is located in the same project
    No additional setup
  • If a targets is located in different projects using cross-project reference[About]
    Specify search path

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 Binaries and 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

[Implicit dependency]

[Vocabulary]

Medlin answered 6/12, 2019 at 19:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.