ios SRCROOT 和 PROJECT_DIR 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36323031/
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-08-31 08:48:11  来源:igfitidea点击:

What the different between SRCROOT and PROJECT_DIR?

iosxcodeenvironment-variables

提问by childrenOurFuture

In Xcode, we have to configure many paths in the Build Settings, then we will deal with the $(SRCROOT)and $(PROJECT_DIR), But what the difference between them, can you show me an example, thx a lot.

在Xcode中,我们必须在Build Settings中配置很多路径,然后我们将处理$(SRCROOT)$(PROJECT_DIR),但是它们之间有什么区别,你能举个例子吗,谢谢。

采纳答案by SwiftArchitect

Exchangeable in practice, while the documentation makes these subtle theoretical distinctions:

在实践中可交换,而文档则做出了这些微妙的理论区别:

  1. SRCROOT

    Directory path. Identifies the directory containing the target'ssource files: contains the path to the projectfile that defines the target.

    SOURCE_ROOTis an undocumented alias to SRCROOT

  2. PROJECT_DIR
    Identifies the directory containing the project(.xcodeproj)
    $(PROJECT_DIR)/buildis used as the create the default value for:

    • Intermediate Build Files Path OBJROOT
    • Build Products Path SYMROOT

    Typically these paths are not set per target, but are set per-project or per-user.

  3. PROJECT_FILE_PATH
    Identifies the project itself.
    Equivalent to $(PROJECT_DIR)/$(PROJECT_NAME).xcodeproj

  1. SRCROOT

    目录路径。标识包含目标源文件的目录:包含定义目标项目文件的路径。

    SOURCE_ROOT是一个未记录的别名 SRCROOT

  2. PROJECT_DIR
    标识包含项目的目录( .xcodeproj)
    $(PROJECT_DIR)/build用作创建默认值:

    • 中间构建文件路径 OBJROOT
    • 构建产品路径 SYMROOT

    通常,这些路径不是按目标设置的,而是按项目或按用户设置的。

  3. PROJECT_FILE_PATH
    标识项目本身。
    相当于$(PROJECT_DIR)/$(PROJECT_NAME).xcodeproj

Conceptually different (#1 is about the project which defines the targetwhile #2 is about the project independentlyof any target), they are always pointing to the same location since you are, in essence, always building a target.

在概念上不同(#1 是关于定义目标的项目,而#2 是关于独立于任何目标的项目),它们总是指向同一个位置,因为本质上你总是在构建一个目标。

References

参考

Xcode 8.3 Build Settings reference
Xcode Build System Guide(Retired 2016-09-29)

Xcode 8.3 Build Settings 参考
Xcode Build System Guide(Retired 2016-09-29)

回答by Baig

SRCROOT& PROJECT_DIRare same macros have same effect.PROJECT_DIRmakes more sense when talking about frameworks.

SRCROOT&PROJECT_DIR是相同的宏具有相同的效果。PROJECT_DIR在谈论框架时更有意义。