14

I was trying to look for an example of using an Aggregate Target in Xcode4, including its purpose and why a developer should use it.

Do you have any reference link, especially from Apple Developer web site?

Richard
  • 3,198
  • 27
  • 40
Leonardo
  • 9,275
  • 15
  • 43
  • 86

3 Answers3

12

Aggregate Target

Xcode defines a special type of target that lets you build a group of targets at once, even if those targets do not depend on each other. An aggregate target has no associated product and no build rules. Instead, an aggregate target depends on each of the targets you want to build together. For example, you may have a group of products that you want to build together. You would create an aggregate target and make it depend on each of the product targets. To build all the products, just build the aggregate target.

An aggregate target may contain a custom Run Script build phase or a Copy Files build phase, but it cannot contain any other build phases. Any build settings that the aggregate target contains are not interpreted but are passed to the build phases that the target contains.

Source

Community
  • 1
  • 1
chunkyguy
  • 3,233
  • 1
  • 26
  • 33
4

One reason I use an aggregate target is to package up my application into a .dmg or .zip for distribution. I set the application's target as a dependency, then run a script phase. You could also build and run other tools that either modify the app or help with the packaging, etc.

Richard
  • 3,198
  • 27
  • 40
  • 1
    Ah... Can you please elaborate on how to integrate this with Xcode "Archiving" ? I do exactly what you claim here - but since I need to use the "Archive" build-step for correctly sign my components, and installer package and the .dmg containing it - I'd like my stuff to be correctly archived too. – Motti Shneor May 22 '18 at 15:02
0

An aggregate target does not directly generate a build product. This target does not have Build Rules, but it has Build Phase with Dependencies, Copy Files Phase and Run Script Phase. It can help you to manage other targets to build a product. This target can be a dependency of other target or can be called outside via a related schema.

For example aggregate target is used to create a Universal framework, Umbrella framework, auto-versionning, embedding frameworks in iMessage apps with Xcode 8.0

To create aggregate target

New Target -> Cross-platform -> Aggregate

[Vocabulary]
[Read more about Xcode structure]

yoAlex5
  • 13,571
  • 5
  • 105
  • 98