XCode 框架参考路径和构建输出目录

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

XCode Framework Reference Paths and Build Output Directory

iosxcodemacosframeworks

提问by GTAE86

I have a workspace, Application.xcworkspace, that builds two frameworks and an executable that uses those frameworks. Here is roughly how they are laid out:

我有一个工作区 Application.xcworkspace,它构建了两个框架和一个使用这些框架的可执行文件。以下是它们的大致布局:

  • Framework_1 - Built and output to ugly DerivedData path.

  • Framework_2 - Depends on Framework_1, which is included in the Frameworks area of the project and specified in the "Link Binary with Libraries" Build Phase, and output to ugly DerivedData path.

  • Application - Depends on Framework_1 and Framework_2, which are included in the Frameworks area of the project and specified in the "Link Binary with Libraries" Build Phase. Output directory is again that ugly DerivedData path.

  • Framework_1 - 构建并输出到丑陋的 DerivedData 路径。

  • Framework_2 - 依赖于 Framework_1,它包含在项目的 Frameworks 区域中并在“Link Binary with Libraries”构建阶段指定,并输出到丑陋的 DerivedData 路径。

  • 应用程序 - 取决于 Framework_1 和 Framework_2,它们包含在项目的 Frameworks 区域中并在“Link Binary with Libraries”构建阶段中指定。输出目录又是那个丑陋的 DerivedData 路径。

The problem I have is that the paths in the project file for the referenced frameworks are the DerivedData ugly path - they are like ../../Library/Developer/XCode/DerivedData/Application-longuglyuniquestring/Build/Products/Release/Framework_1.framework.

我的问题是引用框架的项目文件中的路径是 DerivedData 丑陋的路径 - 它们就像 ../../Library/Developer/XCode/DerivedData/Application-longuglyuniquestring/Build/Products/Release/Framework_1 。框架。

If I copy the source to another directory, or check it into version control and check it out to another machine, then those framework paths are no longer valid. They get re-generated. The referenced frameworks show up as red in the project.

如果我将源代码复制到另一个目录,或者将其检入版本控制并将其检出到另一台机器,那么这些框架路径不再有效。它们得到重新生成。引用的框架在项目中显示为红色。

So far, when I want to build the workspace in another folder, the way I have fixed the problem is to:

到目前为止,当我想在另一个文件夹中构建工作区时,我解决问题的方法是:

  • Build the workspace - Framework_1 builds.
  • Go to the "Products" node for that framework and show it in Finder.
  • Copy the new ugly path.
  • Open the project files for Framework_2 and Application and correct the path for Framework_1 and Framework_2.
  • All the red items should be resolved and everything should build.
  • 构建工作区 - Framework_1 构建。
  • 转到该框架的“产品”节点并在 Finder 中显示它。
  • 复制新的丑陋路径。
  • 打开 Framework_2 和 Application 的项目文件并更正 Framework_1 和 Framework_2 的路径。
  • 所有的红色项目都应该得到解决,一切都应该建立。

That process is tedious and I am lucky the project file can be edited. It is worse for colleagues that do not understand the little I know about the project files, and just want to check the code out and have it build.

这个过程很乏味,我很幸运可以编辑项目文件。对于那些不了解我对项目文件知之甚少,只想检查代码并构建它的同事来说,情况更糟。

Is there something I need to do to the Build Output Directory for the frameworks? I have been leery of changing it since the ugly path is recommended. Is there a copy files option I can use to put those frameworks in some predictable location relative to my workspace?

我需要对框架的构建输出目录做些什么吗?因为推荐了丑陋的路径,所以我一直对改变它持怀疑态度。是否可以使用复制文件选项将这些框架放置在相对于我的工作区的某个可预测位置?

Any help would be appreciated. I am sure I am missing something simple - it makes no sense that code checked out of source control or copied to another directory would not just build.

任何帮助,将不胜感激。我确信我遗漏了一些简单的东西——从源代码管理中检出或复制到另一个目录的代码不会只是构建,这是没有意义的。

回答by GTAE86

Looks like there is a way to set the DerivedData directory on a per-workspace basis - Xcode 4 - build output directory

看起来有一种方法可以在每个工作区的基础上设置 DerivedData 目录 - Xcode 4 - 构建输出目录

I just set DerivedData to be relative to my workspace, then edited the project files accordingly. The only down-side is if I were to use one of those projects in another workspace that was using the default DerivedData path, I would have to change them back.

我只是将 DerivedData 设置为相对于我的工作区,然后相应地编辑了项目文件。唯一的缺点是,如果我要在另一个使用默认 DerivedData 路径的工作区中使用这些项目之一,我将不得不将它们改回来。

Many thanks to user DaGaMs - he got an upvote.

非常感谢用户 DaGaMs - 他得到了赞成票。

I am still seeing bad behavior from XCode 5: I got the project working on my machine. Copied it to another, lower, directory and verified it still worked. Exited XCode and copied the containing directory to a network drive, and from there onto another Mac. When I opened it on the other Mac it was like I never made some of the changes. Even worse, as I worked to fix it, XCode went nuts and added 6 extra '\' characters to each end of my FRAMEWORK_SEARCH_PATHS paths!

我仍然看到 XCode 5 的不良行为:我让项目在我的机器上运行。将其复制到另一个较低的目录并验证它仍然有效。退出 XCode 并将包含目录复制到网络驱动器,然后从那里复制到另一台 Mac。当我在另一台 Mac 上打开它时,就像我从未进行过一些更改。更糟糕的是,当我努力修复它时,XCode 发疯了,并在我的 FRAMEWORK_SEARCH_PATHS 路径的每一端添加了 6 个额外的“\”字符!

Part of the problem stems from the subproject directories in my app being absolute rather than relative. The projects in the top of the workspace are "Relative to Group", so I changed the subprojects to have the same attribute. That seems to have solved the problem, though for some reason when I copy all the files to another machine, the Derived Data redirection does not go with it.

部分问题源于我的应用程序中的子项目目录是绝对的而不是相对的。工作区顶部的项目是“相对于组”,因此我将子项目更改为具有相同的属性。这似乎解决了问题,但由于某种原因,当我将所有文件复制到另一台机器时,派生数据重定向并没有随之而来。