Xcode 如何从编译中排除文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38477532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode how to exclude FOLDERS from compilation?
提问by Nik Kov
采纳答案by Caleb Kleveter
From looking at the post you link to. Here is how you do it:
从查看您链接到的帖子。这是你如何做到的:
Go to Build Settings.
Press the plus button and select "Add User-Defined settings"
转到构建设置。
按加号按钮并选择“添加用户定义的设置”
- Give the new field the name of
EXCLUDED_SOURCE_FILE_NAMES
.
- 将新字段命名为
EXCLUDED_SOURCE_FILE_NAMES
。
- Add the path to the folder:
<Path>/FolderToIgnore/*
. The asterisk denotes allthe file in the folder.
- 添加文件夹的路径:
<Path>/FolderToIgnore/*
. 星号表示文件夹中的所有文件。
That should do it.
那应该这样做。
Note:Make sure you add this to the right target.
注意:确保将其添加到正确的目标。
回答by 1mike12
回答by Pritish Vaidya
This answer covers only how to exclude the files from the build or the matching file patterns.Exclude from the path or the folder has currently not been implemented in the Xcode
此答案仅涵盖如何从构建或匹配文件模式中排除文件。从路径或文件夹中排除目前尚未在Xcode中实现
- Select the
editor
- Select
Add Build Setting
- In Add Build Setting select
Add User Defined Settings
for this select the project for which you want to add the user defined settings. - Select the name of it as
EXCLUDED_SOURCE_FILE_NAMES
- Set the value as filename patterns,the files you want to exclude.
- 选择
editor
- 选择
Add Build Setting
- 在“添加构建设置”中
Add User Defined Settings
,为此选择要为其添加用户定义设置的项目。 - 选择它的名称作为
EXCLUDED_SOURCE_FILE_NAMES
- 将值设置为文件名模式,您要排除的文件。
or
或者
You can use the File Inspectorand in the target membershipsimply uncheck
the file which you do not want to include in your build
您可以使用文件检查器,并在目标成员资格中简单地uncheck
使用您不想包含在构建中的文件
Similarly the same thing can be done compile sourcescategory where you can select the file
which you want to add
to your build
.
同样,同样的事情可以在编译源类别中完成,您可以select the file
在您想要add
的build
.
回答by Ohifriend
Can't comment, but wanted to note that, unless I'm doing something wrong, when using the EXCLUDED_SOURCE_FILE_NAMES
build setting as explained in the other answered, excluding a folder using something like */Folder/*
won't exclude anything within sub-folders of Folder
, but only files within it directly. If you had another folder, eg. /Folder/Subfolder/
, you'd have to include */Folder/Subfolder/*
as well in order to exclude any files within it. At least this is the case in Xcode 10.3.
无法发表评论,但要注意的是,除非我做错了什么,否则在使用EXCLUDED_SOURCE_FILE_NAMES
另一个回答中解释的构建设置时,使用类似的*/Folder/*
内容排除文件夹不会排除 的子文件夹中的任何内容Folder
,但仅直接在里面的文件。如果您有另一个文件夹,例如。/Folder/Subfolder/
,您还必须包含*/Folder/Subfolder/*
以排除其中的任何文件。至少在 Xcode 10.3 中是这种情况。
Example:
例子:
[Folder]
item.txt
[Subfolder]
image.png
info.plist
*/Folder/*
would exclude item.txt
and info.plist
, but not image.png
.
*/Folder/*
会排除item.txt
和info.plist
,但不会image.png
。
*/Folder/Subfolder/*
would exclude image.png
.
*/Folder/Subfolder/*
会排除image.png
。