What is target membership in Xcode 4
Asked Answered
H

2

19

I am searching for an example for target membership in Xcode. I am a bit confused about what it means exactly. For example, I have two different target membership. myApp and myAppTests. What does it mean if I specify a file (say myAppFile.h) to be part of myAppTests but not myApp? What happens exactly when my app build and run?

Thanks

Heteropolar answered 29/11, 2011 at 4:50 Comment(0)
C
16

Generally header files are not members of targets. Making an implementation file a member of a target tells Xcode to compile the file when you build the target. In your example Xcode compiles the file myAppFile.m when you build the myAppTests target but not when you build the myApp target.

When you have an application target and a unit testing target, your application's implementation files should be members of the application target. Your unit testing classes' implementation files should be members of the unit testing target.

Currin answered 29/11, 2011 at 5:24 Comment(0)
P
2

Target Membership

When you add a class into Target Membership it will be a part of your target and binary. It is a reflection of Build Phases.

Case 1: General using during development e.g sharing code between different targets

Case 2: Tests

Case 3: For example, when you create a library or framework you should create a .modulemap[About] which includes an umbrella header. Every imported header in the umbrella should have a public target membership.

You can setup a visibility via:

`Target Membership` in the `Inspector` tab 
//or
Project Settings -> Target -> Build Phases
    .h -> Headers
    .m, .swift -> Compile Sources
    .h or umbrella.h and .modulemap -> Copy Files
Payton answered 6/12, 2019 at 16:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.