xcodebuild说不包含方案 [英] xcodebuild says does not contain scheme

查看:138
本文介绍了xcodebuild说不包含方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个古玩问题.

我有一个项目已经在做,并且总是从XCode IDE构建的,并且运行良好.现在,我要设置Bamboo来构建项目,并因此从命令行进行构建.

I have a project that I've worked on and always built from the XCode IDE, and it worked fine. Now I'm setting up Bamboo to build the project and as such am building it from the command line.

问题是,如果我从GIT中检出我的代码,然后使用xcodebuild进行构建,则表明无法找到该方案,但是如果我打开该项目,则会进行构建,然后尝试从中再次构建它带有相同命令的命令行,它可以正常工作.

The issue is, if I check my code out of GIT and then use xcodebuild to build it it says that the scheme cannot be found, but if I open the project, it builds and if I then try to build it again from the command line with the same command, it works.

当我打开项目或正在做一些愚蠢的事情时,XCode在做什么呢?也许排除了我不应该的.gitignore文件?

What magic is XCode doing when I open the project or am I doing something dumb, maybe excluding a file in my .gitignore that I shouldn't?

推荐答案

相对于.xcscheme文件,您肯定处于正确的轨道上-在设置自己的项目时出现了此问题!

You are definitely on the right track with respect to the .xcscheme file -- I had this problem appear while setting up my own projects!

对于后代,或者至少是有人从搜索中到达此地,这里有两种说法:我很忙,所以请事实",以及更多涉及的讨论和理由.这两个版本都假定您正在尝试从Workspace文件进行构建.如果不是,那么我道歉,因为这主要适用于基于工作空间的项目.

For posterity, or at least anyone getting here from a search, here are two versions of things -- the "I'm busy, so just the facts please" version and a more involved discussion and rationale. Both of these versions assume you are trying to build from a Workspace file; if you aren't then my apologies as this mostly applicable to workspace-based projects.

压缩的修复"版本

根本原因是Schemes的默认行为是将方案保持为私有"状态,直到将它们明确标记为共享为止.如果是命令行启动的构建,则Xcode UI永远不会运行,并且xcoderun工具没有自己的Scheme缓存可以使用.目标是生成,共享和提交您希望Bamboo运行的方案:

The root cause is that the default behavior of Schemes is to keep schemes 'private' until they are specifically marked as shared. In the case of a command-line initiated build, the Xcode UI never runs and the xcoderun tool doesn't have its own cache of Schemes to work with. The goal is to generate, share, and commit the scheme you want Bamboo to run:

  1. 在干净的代码副本上,打开项目的工作区.
  2. 从产品菜单中选择方案>管理方案....
  3. 为项目定义的计划列表出现.
  4. 找到Bamboo正在尝试运行的计划
  5. 确保已选中该方案的共享"框,并且将容器"设置设置为工作区"而不是项目文件本身.
  6. 单击确定"以关闭管理方案"表.
  7. 在您的项目中,通过WorkspaceName.xcworkspace/xcshareddata/xcschemes创建了一个新的.xcscheme文件.
  8. 将此文件提交到您的存储库,然后运行Bamboo版本.

更深入的讨论和原理

Xcode 4引入了工作区和方案,以帮助尝试解决一些固有的混乱,这些混乱是与Xcode项目的布线,构建目标以及一起构建配置的机制打交道的.工作区本身具有一组自己的配置数据,这些数据描述它包含的每个较小的数据框",并充当附加.xcodeproj文件的框架以及一组共享配置数据的框架,该共享配置数据已镜像到每个开发人员机器或CI系统. 这既是工作区的强大功能,也有陷阱-有1种方法可以让人们1​​00%正确地配置东西,但将其放置在错误的容器中,或者2)放置在正确的容器中,但配置不当.从而使数据无法被系统的其他部分访问!

Xcode 4 introduced Workspaces and Schemes as a way to help try and tame some of the chaos that is inherent to dealing with the mechanics of wiring related Xcode projects, build targets, and build configurations together. The workspace itself has its own set of configuration data that describes each of the smaller 'boxes' of data it contains and acts as a skeleton for attaching .xcodeproj files and a set of shared configuration data that gets mirrored to each developer machine or CI system. This is both the power and pitfall of Workspaces -- there are 1) lots of ways in which one can get things configured 100% correctly, but put into the wrong container or 2) put into the correct container, but configured improperly thus rendering data inaccessible by other parts of the system!

Xcode 4方案的默认行为是在将项目添加到Workspace文件时自动生成新方案.那些已经添加了几个.xcodeproj文件的人可能已经注意到,您的方案列表很快变得不规则,尤其是在添加,删除然后再读入同一工作区的项目文件中.自动生成或手动创建的所有方案默认为仅对当前用户可见的私有"方案,即使.xcuserdata文件已提交了项目的数据和配置.这是该隐秘构建错误的根本原因,xcodebuild的Bamboo报告–因为Bamboo通过命令行而不是Xcode UI操作该构建,所以Schemes没有机会自动生成,仅依赖那些在工作区本身中定义.假设您已经配置Bamboo来使用以下命令从工作空间构建:

The default behavior of Xcode 4 schemes is to automatically generate new schemes as projects are added to the Workspace file. Those of you that have added several .xcodeproj files may have noticed that your scheme list quickly becomes unruly especially as project files are added, then removed, and then readded to the same workspace. All schemes, autogenerated or manually created, default to being 'private' schemes visible only to the current user even when .xcuserdata files are committed with the project's data and configuration. This is the root cause of that cryptic build error Bamboo reports from xcodebuild -- Because Bamboo operates the build through the command line and not the Xcode UI, it doesn't have an opportunity for Schemes to get automatically generated and relies only on those that are defined in the workspace itself. Assuming you've configured Bamboo to build from a workspace using a command like this:

xcodebuild -workspace MyWorkspace.xcworkspace -scheme MyApplication -configuration Debug

xcodebuild会寻找文件<'scheme'参数值> .xcscheme存在于<''workspace'参数值>/xcshareddata/xcschemes中.

xcodebuild goes looking for file <'scheme' Parameter Value>.xcscheme existing at <'workspace' Parameter Value>/xcshareddata/xcschemes.

很明显,有很多方法可以配置Bamboo和工作区,因此请记住,您的唯一配置可能不会100%映射到此处显示的内容.关键要点:

Obviously there are bunches of ways in which one could configure both Bamboo and a workspace, so keep in mind that your unique configuration may not map 100% to what is presented here. The key takeaways:

  1. Xcode UI神奇地处理的某些自动化任务无法通过Xcodebuild CLI使用.
  2. 您可以将方案和构建配置数据附加到容器层次结构"中的许多地方-确保将数据保存在正确的容器(工作区,项目和/或构建目标)中
  3. 考虑xcodebuild工具可能在容器层次结构中的何处寻找配置数据;
  4. 使用'-workspace'或'-project'参数是一个很好的指示.
  1. Certain automated tasks the Xcode UI magically takes care of are not available via the Xcodebuild CLI.
  2. You can attach scheme and build configuration data to many places in the 'container hierarchy' -- Make sure your data winds up in the right container (Workspace, Project, and/or Build Target)
  3. Consider where in the container hierarchy the xcodebuild tool may be looking for configuration data; a great indicator of where it will start looking is based on the use of '-workspace' or '-project' arguments.

共享"框已被选中...现在是什么?

我在自己的Bamboo实例上遇到了同样的问题;事实证明,在我的存储库中提交的方案已经过时,并且最新版本的命令行工具无法正常处理它.既然以前存在过,我仔细检查了设置以确保没有明显的自定义方案,删除并重新创建该方案以确保将其标记为"Shared",然后将新的.xcscheme文件重新提交给存储库.

I encountered this same issue on my own Bamboo instance; it turned out that the scheme that was committed in my repository was outdated and the latest version of the command line tools wasn't handling it gracefully. Since this existed previously, I took a look through the settings to make sure there wasn't anything glaringly custom about the scheme, deleted and recreated the scheme ensuring that I marked it as 'Shared', and recommitting the new .xcscheme file to the repository.

如果一切看起来都很好,并且重建它不能解决问题,请仔细检查容器设置-将方案附加到层次结构中的错误容器真的很容易!

If everything looks good and rebuilding it doesn't solve the issue, double check that container setting -- it is really easy to get that scheme attached to the wrong container in the hierarchy!

这篇关于xcodebuild说不包含方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆