定义方案,从终端的X code的PhoneGap项目 [英] Define schemes in an xcode phonegap project from terminal

查看:189
本文介绍了定义方案,从终端的X code的PhoneGap项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个脚本来存档的PhoneGap项目的一部分的iOS。该脚本湿巾,该项目所在的目录,然后使用从源代码控制的最新code重新填充它。我那么为了构建项目运行 $ PhoneGap的地方共建的ios 。不过,为了归档项目,我需要它的计划来进行定义。我曾尝试构建从命令行的项目,但我得到的消息**构建失败**。截至目前我有code打开X code项目,然后睡了30秒的时间,我等待X code到(我发现让方案定义的唯一方法)工作它的魔力。我的问题是我怎么能既模拟断开X code或者定义命令行的方案。

感谢您事先的任何帮助。


解决方案

这是已知x code计划是略小于彻底的记录和计划有被有些神奇的这种感觉,直到你看到一个完全公平的问题他们钩到构建过程作为一个整体。

根据您所寻求的解决办法

,这听起来好像你需要推广一项计划,被共享,让自动化工具(或其他开发者)不必首先打开你的项目,等待X code到自动生成的默认方案。这是一个完全正常的,从开发人员的要求努力使与其X code项目,持续集成系统或作用于一个X code 4或X code 5项目的其他命令行工具的工作。好消息是,有X code-本土的方式来配置你的项目,而不诉诸凌乱或容易出错的解决方法。

TL; DR版本:

有关方案默认的X code行为是将它们视为一个特定的开发人员设置,而不是与其他开发人员或工具分享。我们需要促进项目的方案被共享,并提交这些改变你的版本控制系统:


  1. 启动你的项目的一个干净的检出。

  2. 导航X code'S菜单:产品>方案>管理方案... 菜单选项

  3. 该计划表的左上角取消选中自动创建方案

  4. 选中共享复选框旁边应提供给所有开发者和用户构建系统方案。

  5. 最后提交所有项目变回你的版本控制系统。

这将使使用该项目的所有开发人员共享一个单一的计划,无论OS X用户名,并使其使得通过 X codebuild 或无人看管的构建建立首选工具将有计划的工作。

...而现在,到了较长的答案好奇

首先一点背景知识之前,我们潜入你直接的问题:

目标:的应用程序,静态库,捆绑,或者更一般地从源头code构建的产品,资产的Plist,构建设置和其他文件包含在项目中。当构建操作则通过X code'S运行按钮或通过命令行工具 X codebuild

构建配置:命名集的构建设置,可以通过一个人类可读标签进行标识。默认情况下,所有的X code项目开始产生建立与透明度在调试他们的应用程序和剥离产生的这个诊断信息并优化构建一个释放配置帮助开发量最大的目标的调试配置构建以减小其大小。一些开发商选择根据自己的球队的需要创建额外的配置:特设可能会创建这样的签名身份和发放模板设置,可以为code通过一个特设的provisioning profile签署安装应用程序而改变。 AppStore的或分配是其他常见的自定义生成的配置在其他项目之一可能会看到。

动作:一组支持参与开发,诊断和产品测试的不同阶段相关活动。由于写作时有六大行动:生成,运行,测试,档案,分析和存档。作为一个开发者这两个你最经常使用的是构建和运行。

建设方案:的X code 4项发明用于管理项目构建目标相关性,建立并行化选项,在指定的构建目标。每个计划允许开发者选择只有一个构建配置(例如,调试或发行)的一个项目生命周期的每一个行动(生成,运行等),并定义相关的其他行为或选项与具体行动。例如,在一个方案中的配置文件操作允许开发者选择哪个诊断仪将默认在Instruments.app剖析code时被加载。

记住这些定义,让我们回到你的问题:

如何可以我要么可模拟打开X code或以其他方式在命令行中定义的计划?

很简单:你不需要做任何,有制作计划提供一个X code-原生机制,我们只是需要做一些小的方案重新配置,让你起来,然后运行提交这些更改版本控制(我会将此称为对这个答案的其余部分'SCM')

您所面临的问题为X code的缺省项目行为时,涉及到持续的项目设置。默认情况下,很多事情都考虑的具体开发人员的设置和驻留在一组文件映射到(在某一时刻更多关于这个)打开在X code项目本身的帐户的特定用户名。管理这些设置的策略可以是蒸馏水下降到规则是X code设置被认为是开发商不公开,直到明确提倡共享。虽然这是之前于X code 4×code版本present,但直到引进计划为调用的主要手段的建立,这种做法导致开发团队和他们的持续集成系统的问题。

方案走过来巩固根据X code的早期版本设置屏幕的大量成一个单一的编辑器窗口,开发商可以看看在最高级别设置为每个不同的行动阶段应用程序:


  • 当运行构建的动作,人们可以定义哪些指标需要得到构建,或者如果X code应该尝试找出自身构建依赖关系。

  • 对于运行行动中,选择构建配置应该使用以及哪些调试器来使用。

  • 对于一个测试的行动中,选择构建配置也应该被作为测试类和测试数据群应该被用来测试应用程序行为中。

  • ...等...还有很多其他高级设置,但我要离开他们探索作为练习读者...还是有机会提出另一个质疑SO!

在每一种情况下,这些设置造成的连带效应的东西 - 选择调试配置保持在应用程序尽可能地帮助开发人员追踪问题的根源尽可能多的诊断数据,这反过来会调用调试的具体构建设置中配置的构建目标本身也可能会遇到调试特定的脚本或启用调试的具体设置。

当然,这些选择需要有地方住,使他们能够发展会话之间或在极少数情况下是X code决定崩溃被持久化。的开发者公开,直到推出了统治行为苏preME这些方案设置在.X codeproj文件本身内的xcuserdata文件夹中坚持 - 这仍然持有这些项目的事实,居住作为.xcworkspace的一部分。

您可以在自己的项目中看到自己。首先,确保你有一个干净的版本的code的工作,然后打开X code项目或工作,以确保默认方案您个人的版本可用时,我们通过您的项目文件走路:


  1. 从X code到搜索开关,然后导航到项目的结账目录。

  2. 在为您的项目.X codeproj文件点击右键并选择显示包内容。如果你使用一个工作区,仍然选择包含项目文件的.X codeproj,而不是.xcworkspace本身

  3. 导航到xcuserdata。

根据对已经参与了这个项目,或与已犯本项目不同的用户名不同的机器数开发人员的数量,这是明显的可能有多个.xcuserdatad文件夹中。


  1. 选择符合您的OS X的用户名的文件夹。对于我来说,我的OS X的用户名是bmusial所以我会选择'bmusial.xcuserdatad文件夹中。

  2. 导航到xcschemes文件夹中。

  3. 注意,你有两个文件:[目标名称] .xcscheme和xcschemenamagement.plist包含有关计划的订单信息,如果计划应是自动生成的,还是不

啊哈!方案被视为开发者的私人数据和最早推出的项目都是自动生成的!

这实现开始得到在我们需要做的核心 - 这一设计出具体的开发人员xcuserdata夹迁移到所有开发人员共享的东西,从禁用自动模式代以prevent他人落入在今后的陷阱,并提交这些更改回你的供应链管理。切换回X code,让我们重新配置的几件事情:


  1. 导航X code'S菜单:产品>方案>管理方案... 菜单选项

  2. 该计划表的左上角取消选中自动创建方案

  3. 选中共享复选框旁边应提供给所有开发者和用户构建系统方案。

切换回Finder窗口,并去了两个级别返回到.X codeproj文件夹(包含xcuserdata文件夹中的一个)的内容。请注意,您现在有一个'xcshareddata文件夹。此文件夹包含包含现在我们刚刚共享的方案,并在我们自己的xcuserdata文件夹中的.xcscheme走了一个xcschemes文件夹。我们刚刚提拔你的私人计划,作为一个共享,公共计划,将提供给所有开发工具,甚至那些从来没有直接推出了X code ++项目。

提交所有的我们已经取得了(会有一些新的文件夹和文件!)回到你的供应链管理,这样当下次更新其源$ C ​​$ C每个人都收到相同的配置更改的变化!

运行的PhoneGap 接下来的时间将您的Checkout重设为您的指示,但因为你有一个方案致力于将有建立它可以工作的行动。

这给了一枪,让我们知道事情怎么走,如果您遇到任何后续问题或困难沿途。

I'm writing a script to archive the iOS portion of a phonegap project. The script wipes the directory that the project is in and then repopulates it using the latest code from source control. I then run$ phonegap local build ios in order to build the project. However in order to archive the project I need its schemes to be defined. I have tried building the project from the command line but I get the message ** BUILD FAILED **. As of right now I have the code open the xcode project (the only way that I've found to get the schemes defined) and then sleep for 30 second while I wait for xcode to work its magic. My question is how can I either simulate opening xcode or otherwise define the scheme from the command line.

Thanks in advance for any help.

解决方案

This is a completely fair question given that Xcode schemes are somewhat less than thoroughly documented and schemes have this feeling of being somewhat magical until you see how they hook into the build process as a whole.

Based on the workarounds you are seeking, it sounds as though you need to promote a scheme to being "Shared" so that automated tools (or other developers) do not have to first open your project and wait for Xcode to auto-generate the default scheme. This is an entirely normal 'ask' from developers trying to make their Xcode projects work with Continuous Integration systems or with other command line tools acting on an Xcode 4 or Xcode 5 project. The great news is that there are Xcode-native ways to configure your project without having to resort to messy or error prone workarounds.

TL;DR Version:

The default Xcode behavior for schemes is to treat them as a developer-specific setting and not share with other developers or tools. We need to promote your project's scheme to being 'Shared' and commit those changes to your version control system:

  1. Start with a clean checkout of your project.
  2. Navigate Xcode's Menus: Product > Scheme > Manage Schemes... menu option
  3. Uncheck 'Autocreate Schemes' in the upper left corner of the scheme sheet,
  4. Check the 'Shared' checkbox next to the scheme that should be made available to all developer users and build systems.
  5. Finally commit all project changes back to your version control system.

This will make a single Scheme shared across all developer using this project, regardless of OS X username and make it such that unattended builds via xcodebuild or the build tool of choice will have a scheme to work with.

...And now, on to the the longer answer for the curious

First a bit of background before we dive into your direct questions:

Target: The app, static library, bundle, or more generally the 'product' constructed from the source code, assets, plists, build settings, and other files contained within the project. This 'product' is generated when a build operation is invoked either via Xcode's "Run" button or via the command line tool xcodebuild

Build Configuration: A named set of build settings that can be identified by a human-readable label. By default, all Xcode projects start with a "Debug" configuration that generates build targets with the greatest amount of transparency aiding developers in debugging their applications and a "Release" configuration that strips the resulting build of this diagnostic information and optimizes the build to reduce its size. Some developers elect to create additional configurations based on their team's needs: "Ad-Hoc" might be created so that the Signing Identity and Provisioning Profile settings can be changed for code signing the app for installation via an Ad-Hoc provisioning profile. "AppStore" or "Distribution" are other common custom Build Configurations one might see in other projects.

Action: A set of related activities supporting different phases involved in the development, diagnosis, and testing of a product. As of the time of writing there are six actions: "Build", "Run", "Test", "Profile", "Analyze", and "Archive". As a developer the two you will most frequently use are "Build" and "Run".

Build Scheme: An Xcode 4 invention for managing project build target dependencies, build parallelization options, for a specified Build Target. Each Scheme allows a developer to select exactly one Build Configuration (ex. "Debug" or "Release") for each Action ("Build", "Run", etc.) of a project's lifecycle as well as define other behaviors or options associated with that specific Action. For example, the "Profile" action in a scheme allows the developer to select which diagnostic instrument will be loaded by default when Profiling code in Instruments.app.

With these definitions in mind, lets get back to your questions:

How can I either simulate opening xcode or otherwise define the scheme from the command line?

Very simply: You don't need to do either, there is an Xcode-native mechanism for making schemes available and we just need to do some minor scheme reconfiguration to get you up and running then commit those changes to version control (I'm going to refer to this as 'SCM' for the rest of this answer).

The behavior you are facing is Xcode's default project behavior when it comes to persisting project settings. By default, many things are considered developer-specific settings and reside in a set of files mapping to the specific username of the account that opened the Xcode project itself (more on this in a moment). The policy governing these settings could be distilled down to the rule that Xcode settings were considered 'developer private until explicitly promoted to shared'. Although this was present in versions of Xcode prior to Xcode 4, it wasn't until the introduction of Schemes as the primary vehicle for invoking builds that this approach caused development teams and their Continuous Integration systems problems.

Schemes came along and consolidated a great number of settings screens from early versions of Xcode into a single editor window where a developer could take a look at the highest-level settings for each of the different Action phases of the app:

  • When running the "Build" action, one could define which targets need to get constructed, or if Xcode should try and identify build dependencies on its own.
  • For a "Run" action, select which Build Configuration should be used as well as which Debugger to use.
  • For a "Test" action, select which Build Configuration should be used as well as which Test Classes and Test Data Bundles should be used to test application behavior.
  • ...etc...There are lots of other high-level settings but I'm going to leave exploring them as an exercise for the reader...or an opportunity to ask another SO question!

In each case, these settings cause something of a cascade effect -- Selecting a "Debug" configuration keeps as much diagnostic data in the app as possible to aid developers in tracing the source of problems, this in turn would invoke the "Debug" specific Build Settings as configured in the Build Target itself that may also run "Debug" specific scripts or enable "Debug" specific settings.

Naturally, these selections needed to live somewhere so that they could be persisted between Development sessions or on the rare occasion that Xcode decides to crash. The behavior of "Developer private until promoted" reigned supreme and these Scheme settings were persisted in the "xcuserdata" folder within the .xcodeproj file itself -- This still holds true for those projects that reside as a part of an .xcworkspace.

You can see this for yourself in your own project. First, ensure you are working with a clean version of your code, then open the Xcode project or workspace to ensure that your personal version of the default scheme is available when we walk through your project file:

  1. Switch from Xcode to Finder, then navigate to your project's checkout directory.
  2. Right-click on the .xcodeproj file for your project and select 'Show Package Contents'. If you use a workspace, still select the .xcodeproj that contains your project files, and not the .xcworkspace itself
  3. Navigate into "xcuserdata".

Depending on the number of developers that have been involved with this project or the number of different machines with different usernames that have committed against this project, it is distinctly possible to have more than one .xcuserdatad folder.

  1. Select the folder that matches your OS X username. For me, my OS X username is 'bmusial' so I would select the 'bmusial.xcuserdatad' folder.
  2. Navigate into 'xcschemes' folder.
  3. Observe that you have two files: "[TARGET NAME].xcscheme" and "xcschemenamagement.plist" that contains information about the order of schemes and if schemes should be auto-generated or not.

Ah ha! Schemes are treated as developer-private data and are auto-generated on the first launch of the project!

This realization starts to get at the core of what we need to do -- migrate this scheme out of the developer-specific xcuserdata folder into something shared among all developers, disable auto-scheme-generation to prevent others from falling into the trap in the future, and commit those changes back to your SCM. Switch back to Xcode, let's reconfigure a few things:

  1. Navigate Xcode's Menus: Product > Scheme > Manage Schemes... menu option
  2. Uncheck 'Autocreate Schemes' in the upper left corner of the scheme sheet,
  3. Check the 'Shared' checkbox next to the scheme that should be made available to all developer users and build systems.

Switch back to your Finder window and go up a two levels to get back to the contents of the .xcodeproj folder (the one that contains a 'xcuserdata' folder). Notice that you now have a 'xcshareddata' folder. This folder contains a 'xcschemes' folder that contains the scheme we just shared and the .xcscheme in our own xcuserdata folder is now gone. We have just promoted your private Scheme as a shared, public scheme that will be available to all developers and tools, even those that have never launched the Xcode project directly.

Commit all of the changes we've made (there will be some new folders and files!) back to your SCM so that everyone receives the same configuration changes when the next time they update their source code!

The next time you run phonegap it will reset your checkout as your indicated but because you have a scheme committed it will have build actions it can work with.

Give this a shot and let us know how things go and if you run into any followup questions or problems along the way.

这篇关于定义方案,从终端的X code的PhoneGap项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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