Nikita Pestrov
Nikita Pestrov

Reputation: 5966

Is every single file compiled in Objective-C?

I would like to know, which code is compiled when i build the project in Objective-C - every single line of code in my project, or only those, that are called from the main.c and then from the ones that are called from them?

I mean, does the compiler separate the project to the simply connected domains and compiles the one that is linked to the main, or it just compiles it all?

Upvotes: 2

Views: 408

Answers (3)

vikingosegundo
vikingosegundo

Reputation: 52227

A Xcode project consists of one or more targets.

For each target you can define, what *.m-files get compiled

compile for targets

if you add a new file to the project, you can specify to what target it will be added. (actually this is a place, where I often see, that the main target is not selected — beware)

enter image description here

Upvotes: 2

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726479

All files in your project get compiled, except for the header files that are not included from any of the .m files, or headers the inclusion of which is suppressed conditionally.

Upvotes: 3

user529758
user529758

Reputation:

The compiler does not perform semantical analysis on your code. It compiles exactly what you tell it to compile -- Xcode generally invokes the compiler in a way that it compiles every file into your application. However, it's unnecessary to compile/link the files from which no classes/functions are used; although not compiling files from which you use classes/functions results in a linkage error (that is, the compiler won't be able to find some symbols in the binary file while putting together the object code for the final executable).

Upvotes: 4

Related Questions