简体   繁体   English

在不破坏xcodebuild存档的情况下,将os x工具作为iOS项目的一部分进行构建吗?

[英]Build os x tool as part of iOS project without breaking xcodebuild archive?

Each time I build my iOS project, I'd like to it also build a couple OS X projects. 每次构建iOS项目时,我都希望它也构建几个OS X项目。 These are command line tools. 这些是命令行工具。 I don't care if they're included in the Archive, I just want to make sure they compile correctly each and every time. 我不在乎它们是否包含在存档中,我只是想确保它们每次都能正确编译。

They're little command line tools for specific tasks which access the same libraries. 它们只是用于访问相同库的特定任务的命令行工具。 In the past, I've built these far less frequently and as a result they suffer from code rot. 过去,我很少频繁地构建它们,因此它们会遭受代码腐烂的困扰。 I'd like to build them each time I build the iOS project, even when I just Build in Xcode. 每当我构建iOS项目时,我都想构建它们,即使我只是在Xcode中构建。

To do this, I tried dragging the projects into my iOS project and set them as dependancies. 为此,我尝试将项目拖到我的iOS项目中并将其设置为依赖项。

This works fine in the IDE, but when I try to build via xcodebuild: 这在IDE中工作正常,但是当我尝试通过xcodebuild进行构建时:

xcrun xcodebuild -sdk iphoneos -workspace AppName.xcworkspace \
    -scheme AppName archive

I get an error that looks like this: 我收到一个看起来像这样的错误:

=== BUILD TARGET dslfi OF PROJECT dslfi WITH CONFIGURATION Release ===

Check dependencies
target specifies product type 'com.apple.product-type.tool', but there's no such
product type for the 'iphoneos' platform

** ARCHIVE FAILED **

The following build commands failed:
    Check dependencies
(1 failure)

Is there any way to continue to build these each time I build while still satisfying xcodebuild ? 在我仍然满意xcodebuild有什么方法可以继续构建这些吗?

  1. You can add any number of targets (iOS app, static lib, contole app, etc) into same project. 您可以将任意数量的目标(iOS应用,静态库,contole应用等)添加到同一项目中。
  2. Then you should create another target - 然后,您应该创建另一个目标- *汇总*目标
  3. Then you have options: 然后,您可以选择:

3.1 Go to scheme settings for aggregate target and add other targets: 3.1转到计划设置的汇总目标并添加其他目标: 目标 where you can specify actions you want to perform on certain target 您可以在其中指定要对特定目标执行的操作

3.2 You may pick aggregate target and go to build settings and add other targets as a dependencies for this target. 3.2您可以选择汇总目标并进行构建设置,并添加其他目标作为该目标的依赖项。

Option 3.1 seems to be the one you need: you can add as many targets as you wish to be build. 选项3.1似乎是您需要的选项:您可以添加任意数量的目标。 And you can specify another target for running. 您可以指定另一个运行目标。 So you'll have something like: 因此,您将获得以下内容:

targets:
target 1 - iOS app
target 2 - other app
target 3 - other app
target 4 - aggregate target

scheme configuration for target 4
build section:
 target 1
 target 2
 target 3
run section:
 executable: target 1 (iOS app)

Once this is completed you may use your scheme to do builds xcodebuild -scheme your_scheme [...other options...] archive 完成此操作后,您可以使用您的方案来构建xcodebuild -scheme your_scheme [...other options...] archive


UPDATE UPDATE

You can skip creation of aggregate target. 您可以跳过创建聚合目标。 You can directly create new scheme and to the configuration you want without involving aggregate target. 您可以直接创建新方案并创建所需的配置,而无需涉及聚合目标。

UPDATE 2 更新2

Make sure to share your scheme to be able to keep it in source control. 确保共享您的方案,以便能够将其保留在源代码管理中。

UPDATE 3 更新3

The option w/o aggregate target is more preferable way to achieve this in case if your targets are not depend on each other directly (as far as I understand you). 如果您的目标不直接相互依赖(据我所知),则不带聚合目标的选项是实现此目标的更可取的方法。 This is the main purpose for schemes. 这是计划的主要目的。

A scheme is a collection of settings that specify which targets to build, what build configuration to use, and the executable environment to use when the product specified by the target is launched. 方案是设置的集合,这些设置指定启动目标指定的产品时要构建的目标,要使用的构建配置以及要使用的可执行环境。 When you open an existing project (or create a new one), Xcode automatically creates a scheme for each target. 当您打开一个现有项目(或创建一个新项目)时,Xcode会自动为每个目标创建一个方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM