Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is target membership in Xcode 4

Tags:

xcode

xcode4

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

like image 352
Codier Avatar asked Nov 29 '11 04:11

Codier


People also ask

What are targets in Swift?

Overview. Each target contains a set of source files that Swift Package Manager compiles into a module or test suite. You can vend targets to other packages by defining products that include the targets. A target may depend on other targets within the same package and on products vended by the package's dependencies.

Where is target membership Xcode?

You can access Target Membership by selecting file and opening the right menu in Xcode (the menu is called Inspectors ). Then, in File Inspector at the bottom of the menu, find Target Membership . It's very important to check all files in your project because without this you won't be able to build a new app target.


2 Answers

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.

like image 171
Swift Dev Journal Avatar answered Sep 22 '22 05:09

Swift Dev Journal


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
like image 27
yoAlex5 Avatar answered Sep 21 '22 05:09

yoAlex5