Xcode - build setting "EXCLUDED_SOURCE_FILE_NAMES" not working
Asked Answered
P

5

6

I am trying to exclude some .swift and .storyboard files from my project (Xcode9) for release build using EXCLUDED_SOURCE_FILE_NAMES. But its not working for me.

Is it possible to give any folder name to exclude it completely? How to give multiple files and folder name?

It is not working if I give path like ../ForlderName/*.

Folder is at the same level as my project.

Is it possible to exclude sub-folders files as well?

I am able to exclude if my hierarchy is

MyProject Folder
 |_
   MyProject Folder 
    |_FolderToBeExcluded

If I gave FolderToBeExcluded/* it is working but file in FolderToBeExcluded's subfolders are not getting excluded.

If my heirachy is like this (ie folder to be excluded and project folder both at same level)

FolderToBeExcluded
MyProject Folder
 |_
   MyProject Folder

If I give ../FolderToBeExcluded/ or $(SRCROOT)/../FolderToBeExcluded/ both are not working

If I give directly any one of the file name which is to be excluded it is getting exclude without giving full path.

Is it the limitation of EXCLUDED_SOURCE_FILE_NAMES?

Plasticizer answered 16/3, 2018 at 18:17 Comment(5)
Probably duplicate of #7537408Monograph
See also twobitlabs.com/2012/01/… etc.Monograph
these links are not solving my problem. I already seen them. I don't want to give every file name.Plasticizer
I am able to exclude if I give individual file name.Plasticizer
You can call it “the limitation” if you like. But anyhow, that is how it works, and it sounds like you understand it perfectly. So there is no real question to ask. This is just a way of complaining that it doesn’t work in some other way. In that case, SO is inappropriate. File a bug with Apple instead.Monograph
I
2

If I gave FolderToBeExcluded/* it is working but file in FolderToBeExcluded's subfolders are not getting excluded.

The reason subfolders are not excluded is because of the /*. That tells it to look for files in FolderToBeExcluded. If you just give FolderToBeExcluded (no slash after) then it will exclude all files in that folder and all subfolders. At least that is what I found.

Irritate answered 3/4, 2019 at 10:6 Comment(2)
This did not work for me using Xcode 12.2. I had to do FolderToBeExcluded/* and FolderToBeExcluded/*/* (as the folder had subfolders).Unfledged
This DID work for me in Xcode 12.5 — I simply wrote the folder name FolderToBeExcluded with no / or *.Absorb
A
1

For me it worked if I define the value of EXCLUDED_SOURCE_FILE_NAMES like this:

$(SRCROOT)/../FolderToBeExcluded/*.*

I am using Xcode 9.4.1

Argyrol answered 2/10, 2018 at 12:22 Comment(1)
A simple asterisks works too: $(SRCROOT)/../FolderToBeExcluded/*Unfledged
A
1

An important gotcha I ran into today is that you can't exclude files within a folder reference, but you can exclude an entire referenced folder.

When you add a folder to Xcode it will ask you if you want to create a group or create a folder reference. If you choose the second option, then you'll need to be aware that you can't exclude files within the folder, but you can exclude the entire folder.

Alcina answered 30/3, 2021 at 22:56 Comment(0)
A
1

My Findings

Lets say

Project
|_ Foo
   |_ Bar
      |_ ToBeExcluded
         |  file.json
         |_ Sub
            |_ subfile.json

I tried ToBeExcluded/* which works excludes file.json but not subfile.json

When trying ToBeExcluded/ and ToBeExcluded the exclusions seems to be ignored as both files are still included

ToBeExcluded/** excludes file.json but includes subfile.json (this is suppose to be recursive but hey)

ToBeExcluded/*/* excludes subfile.json but includes file.json (makes sense I guess)

Kamen suggested using $(SRCROOT) so I tried $(SRCROOT)/Foo/Bar/ToBeExcluded/*.* (which is the same as just $(SRCROOT)/Foo/Bar/ToBeExcluded/*) and it does the same as ToBeExcluded/*, same goes for all other variants and the behaving the same with full path versus without

${PROJECT_DIR} (in my case) translated to the same thing as $(SRCROOT)so did the same thing sadly

My Conclusion (For now)

Sadly for now I think what Im going to do is just exclude ToBeExcluded/* and maybe ToBeExcluded/*/* (will think on this) then just make sure that whenever adding new files to it that preferably in that root folder and if need be grouped in xcode without creating a folder. Worst case a single level of subfolder can be added

Anesthetize answered 17/5, 2023 at 9:33 Comment(0)
M
0

This seems to be the only solution:

  1. Use groups without folders for every subfolder in excluded directory
  2. Exclude ${PROJECT_DIR}/{Path to Excluded Folder}/* in EXCLUDED_SOURCE_FILE_NAMES settings
Melson answered 2/5, 2021 at 10:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.