GangstaGraham
GangstaGraham

Reputation: 9385

Is there a way to build selective files in Xcode?

Is there any way that I can select some files only build selective files and make the build ignore some files in a project?

What compiler flags or Xcode options do I need to use?

Upvotes: 2

Views: 1419

Answers (2)

djromero
djromero

Reputation: 19641

In Xcode, show the project navigator (Cmd-1), click the file you want to remove from the current build. Show the file inspector (Cmd-Opt-1), locate "Target Membership" pane and uncheck the current target. Just check it to add it back.

You can do the same in the target "Compile Sources" phase but you'll need more clicks and if you have a few dozen files you'll need to search it in the list.

The fastest way to stop building temporarily a few lines that you know are wrong or incomplete is to wrap them with

#if 0
// code you want to skip
#endif

Also, if you want to run some experiments you can add a new target that includes those experimental files and add an scheme to build the experiment.

It would be much better if you use git and create an experimental branch, but that's a different story.

Upvotes: 5

Jason
Jason

Reputation: 14605

In the project settings, in Build Settings you can add and remove individual files. However, there is no way to only build some files and not others; you are building all the files in the project.

Upvotes: 3

Related Questions