I have started a new project in Xcode by duplicating an existing folder, because my new app will have a lot of common features with the old one.
The problem is that
Check out the answer here
Xcode: Is there a location/flag to prevent a Class from compiling?
In a nutshell remove the file(s) from the project target.
If you need to remove a lot of files, you could create User-Defined Build Setting which should be called EXCLUDED_SOURCE_FILE_NAMES. And add file names or patterns.
In my case I selected the target I wanted to omit some files, Editor -> Add Build Setting -> Add User-Defined Setting (at first this is greyed out somehow. I selected the project file (just above TARGETS) then reselected target file and was able to create User-Defined Setting) -> name it EXCLUDED_SOURCE_FILE_NAMES -> value something like PREFIX*
Of course you can create User-Defined Setting for whole project that way all targets will have it.
Example how it may look:
Original answer: http://lists.apple.com/archives/xcode-users/2009/Jun/msg00153.html
As dirty hack you can try exclude not files, but its code by using #ifdef NotCompile + #endif
as it's done in C\C++ with .h with adding\removing #define NotCompile
in YOURPROJECT-prefix.pch
In Xcode 9, I am not sure about older versions, go to:
Build Settings -> Build Options -> Excluded Source File Names
Add all file names you want excluded. You can even do wildcard matching.
Bellow is an example of how I have excluded all files starting with dev-
and ending with .cc
for all schemes except for a Debug scheme that is built for Simulator. All Debug Simulator builds exclude files starting with release-
and ending with .cc
Hope this helps!!
UPDATE
I had a similar problem with frameworks and you can exclude frameworks from being embedded into your app with this too!
My problem was that I had 2 frameworks, one was built for the simulator and the other was build for ARM. iTunes Connect complained about me including the simulator one with the app.
If you have many frameworks this help with reducing the app's size too.