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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:03:49  来源:igfitidea点击:

Xcode how to exclude FOLDERS from compilation?

xcodebuildcompilationprojectlinker-flags

提问by Nik Kov

I saw thisand answers in stackO, but didn't find how to exclude folders.

我在stackO中看到了这个和答案,但没有找到如何排除文件夹。

I have 3 folders with a lot of .h , .m and .mm and i need to exclude them temporary, but not to remove references. How can i do that?

我有 3 个文件夹,其中包含很多 .h 、 .m 和 .mm ,我需要暂时排除它们,但不要删除引用。我怎样才能做到这一点?

采纳答案by Caleb Kleveter

From looking at the post you link to. Here is how you do it:

从查看您链接到的帖子。这是你如何做到的:

  1. Go to Build Settings.

  2. Press the plus button and select "Add User-Defined settings"

  1. 转到构建设置。

  2. 按加号按钮并选择“添加用户定义的设置”

enter image description here

在此处输入图片说明

  1. Give the new field the name of EXCLUDED_SOURCE_FILE_NAMES.
  1. 将新字段命名为EXCLUDED_SOURCE_FILE_NAMES

enter image description here

在此处输入图片说明

  1. Add the path to the folder: <Path>/FolderToIgnore/*. The asterisk denotes allthe file in the folder.
  1. 添加文件夹的路径:<Path>/FolderToIgnore/*. 星号表示文件夹中的所有文件。

enter image description here

在此处输入图片说明

That should do it.

那应该这样做。

Note:Make sure you add this to the right target.

注意:确保将其添加到正确的目标。

回答by 1mike12

xcode 9.2

Xcode 9.2

Build Settings> Build Options> Excluded Source File Names

Build Settings> Build Options> Excluded Source File Names

enter image description here

在此处输入图片说明

回答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 Settingsfor 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 uncheckthe 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 filewhich you want to addto your build.

同样,同样的事情可以在编译源类别中完成,您可以select the file在您想要addbuild.

回答by Ohifriend

Can't comment, but wanted to note that, unless I'm doing something wrong, when using the EXCLUDED_SOURCE_FILE_NAMESbuild 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.txtand info.plist, but not image.png.

*/Folder/*会排除item.txtinfo.plist,但不会image.png

*/Folder/Subfolder/*would exclude image.png.

*/Folder/Subfolder/*会排除image.png