-Wmissing-include-dirs和自动包含的头目录

时间:2022-09-30 07:12:01

When building a project in Xcode (3.1.2), 2 folders are automatically added as header directories with the '-I' option:

在Xcode(3.1.2)中构建项目时,会自动将2个文件夹添加为带有'-I'选项的头目录:

/ (ProjPath) / (ProjName) / build / (BuildConfigName) / include  
/ (ProjPath) / (ProjName) / build / (ProjName).build / (BuildConfigName) / (ProjName).build / DerivedSources

I realized this when trying to add -Wmissing-include-dirs to the warnings list in my project. A warning is emitted for both folders. This happens for both Cocoa Applications and C++ Dynamic Libraries. I haven't tried any other project type, but I suppose this behavior applies to any project type.

我在尝试将-Wmissing-include-dirs添加到项目中的警告列表时意识到了这一点。两个文件夹都会发出警告。 Cocoa应用程序和C ++动态库都会发生这种情况。我没有尝试过任何其他项目类型,但我认为这种行为适用于任何项目类型。

  1. How are these folders used by Xcode?
  2. 这些文件夹是如何被Xcode使用的?

  3. Can they be either avoided, or automatically created by Xcode when build begins?
  4. 它们可以避免,还是在构建开始时由Xcode自动创建?

  5. If not, how to successfully use -Wmissing-include-dirs with Xcode?
  6. 如果没有,如何成功使用-Wmissing-include-dirs与Xcode?

Thanks.

1 个解决方案

#1


You can add a script to your target which creates the directories for your:

您可以向目标添加脚本,为您创建目录:

Right-click your target, select Add -> New Build Phase -> New Run Script Build Phase. Drag this build phase to the top of your target, before the "Compile Sources" phase.

右键单击目标,选择Add - > New Build Phase - > New Run Script Build Phase。在“编译源”阶段之前,将此构建阶段拖到目标的顶部。

Then enter a script like this (by double-clicking the phase):

然后输入这样的脚本(通过双击阶段):

mkdir -p "${TARGET_BUILD_DIR}/include"
mkdir -p "${PROJECT_DERIVED_FILE_DIR}"

You can see the various environment variables in the build transcript (Command-Shift-B, click the little text icon, drag the build transcript up.)

您可以在构建脚本中看到各种环境变量(Command-Shift-B,单击小文本图标,向上拖动构建脚本。)

#1


You can add a script to your target which creates the directories for your:

您可以向目标添加脚本,为您创建目录:

Right-click your target, select Add -> New Build Phase -> New Run Script Build Phase. Drag this build phase to the top of your target, before the "Compile Sources" phase.

右键单击目标,选择Add - > New Build Phase - > New Run Script Build Phase。在“编译源”阶段之前,将此构建阶段拖到目标的顶部。

Then enter a script like this (by double-clicking the phase):

然后输入这样的脚本(通过双击阶段):

mkdir -p "${TARGET_BUILD_DIR}/include"
mkdir -p "${PROJECT_DERIVED_FILE_DIR}"

You can see the various environment variables in the build transcript (Command-Shift-B, click the little text icon, drag the build transcript up.)

您可以在构建脚本中看到各种环境变量(Command-Shift-B,单击小文本图标,向上拖动构建脚本。)