简体   繁体   中英

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. 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.

To do this, I tried dragging the projects into my iOS project and set them as dependancies.

This works fine in the IDE, but when I try to build via 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 ?

  1. You can add any number of targets (iOS app, static lib, contole app, etc) into same project.
  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: 目标 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.

Option 3.1 seems to be the one you need: you can add as many targets as you wish to be build. 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


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

Make sure to share your scheme to be able to keep it in source control.

UPDATE 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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