Xcode——如何设置 $(SRCRoot)?

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

Xcode -- how do I set $(SRCRoot)?

xcode

提问by William Jockusch

I am working with someone's library . . . they have set $(SRCRoot) to the location the library was in on their computer. On my computer, it is in a different location. This is messing everything up. How do I change it?

我正在与某人的图书馆合作。. . 他们已将 $(SRCRoot) 设置为图书馆在其计算机上的位置。在我的电脑上,它位于不同的位置。这是把一切都搞砸了。我该如何更改?

回答by mipadi

SRCROOT, like any Xcode build variable, is set in the Build options in the Target settings. However, setting SRCROOTis not supported through the interface options (because you shouldn't set it manually in the first place), so it'll fall under "User-Defined" settings if someone set it manually. You'll want to select it and then delete it. Here's a picture to demonstrate: alt text

SRCROOT与任何 Xcode 构建变量一样,在目标设置的构建选项中设置。但是,SRCROOT不支持通过界面选项进行设置(因为您首先不应手动设置),因此如果有人手动设置,它将属于“用户定义”设置。您需要选择它,然后将其删除。这是一张图片来演示: 替代文字

回答by xhan

SRCRoot is one of the default variables of Xcode

SRCRoot 是 Xcode 的默认变量之一

The best source is probably Apple's official documentation

最好的来源可能是Apple 的官方文档

回答by Alexsander Akers

You must define SRCRoot, not $(...), because the $(x)command returns the value stored in x.

您必须定义SRCRoot,而不是$(...),因为该$(x)命令返回存储在 中的值x

回答by Konstantinos Kontos

Adding a custom user setting (SRCROOT) will work only partially. If your project is under source control you may find that source files are marked red - i.e. Xcode cannot locate them.

添加自定义用户设置 (SRCROOT) 只能部分起作用。如果您的项目受源代码控制,您可能会发现源文件被标记为红色 - 即 Xcode 无法找到它们。

Simply open up the project file into a text editor and replace all occurrences of the old source code folder name.

只需在文本编辑器中打开项目文件并替换所有出现的旧源代码文件夹名称。

Works fine.

工作正常。

回答by CodeBender

These answers are all on the fairly old side, so I wanted to provide something current as of Xcode 7.3.1.

这些答案都比较陈旧,所以我想提供一些最新的 Xcode 7.3.1。

I needed to change the location of the SRCROOT for my Workspace due to some external folders. This was done by moving the .xcworkspace and .xcodeproj to the new location. After that, I just had to update a few items:

由于某些外部文件夹,我需要更改我的工作区的 SRCROOT 的位置。这是通过将 .xcworkspace 和 .xcodeproj 移动到新位置来完成的。在那之后,我只需要更新一些项目:

  • All files inside my project
  • The search path for the Framework (Under build settings / Framework search paths)
  • The location of my info.plist file (Under build settings /, info.plist file)
  • 我的项目中的所有文件
  • 框架的搜索路径(在构建设置/框架搜索路径下)
  • 我的 info.plist 文件的位置(在 build settings / 下,info.plist 文件)

Your mileage may vary based on other items you may have, but this should cover the basics.

您的里程可能会因您可能拥有的其他物品而异,但这应该涵盖基础知识。