Disable some files in an Xcode project from compilation

I started a new project in Xcode by duplicating an existing folder, because my new application will have many common functions with the old one.

The problem is that the new application will not use the structure that I used in the old application. When I deleted the framework, of course, all the files, including this framework, caused errors.

Basically I want to disable all syntax checks, dependency checks, etc. For many files. I want Xcode to ignore these files, although they are in the project tree. Later, when I revise them, I will turn them on again manually. Thus, I can compile and test my small changes for errors, without correcting all the errors that they cause, in the “not fixed” files, which I will correct in the future.

I could remove them from the project tree, and then add them one by one when my work is done, but I do not want to do this because my project tree may get corrupted, and there really needs to be another way to do this.

I tried to delete these files from all target memberships, but that did not help.

+10
ios xcode
source share
4 answers

If you need to delete many files, you can create a User-Defined Build Setting, which should be named EXCLUDED_SOURCE_FILE_NAMES. And add file names or patterns.

In my case, I selected the target that I wanted to omit some files, Editor -> Add Build Setting -> Add User-Defined Setting (first it is painted in some way). I selected the project file (just above TARGETS), then re-selected the target file and was able to create a user preference) -> name it EXCLUDED_SOURCE_FILE_NAMES -> value something like PREFIX *

Of course, you can create a User-Defined Setting for the entire project so that all goals have it.

An example of how this might look: enter image description here

Original answer: http://lists.apple.com/archives/xcode-users/2009/Jun/msg00153.html

+20
source share

In Xcode 9, I'm not sure about older versions, follow the link:

Build Settings → Build Settings → Excluded Source File Names

Add all the file names you want to exclude. You can even do pattern matching.

The following is an example of how I excluded all files, starting with dev- and ending with .cc for all circuits except the debugging circuit created for the simulator. All Debug Simulator assemblies exclude files, starting with release- and ending with .cc

enter image description here

Hope this helps !!

UPDATE

I had a similar problem with frameworks, and you can also exclude frameworks from your application too!

My problem was that I had 2 frameworks, one was built for the simulator, and the other for ARM. iTunes Connect complained about me, including the simulator with the app.

If you have many frameworks, this will help reduce the size of the application.

+8
source share

See the answer here

Xcode: is there a location / flag to compile a class?

In a nutshell, delete the file from the project target.

0
source share

As a dirty hack, you can try to exclude not files, but its code using #ifdef NotCompile + #endif , as was done in C \ C ++ with .h with the addition \ removal of #define NotCompile in YOURPROJECT-prefix.pch

0
source share

All Articles