iOS system provides command-line compilation tool under development environment: Xcodebuild

Source: Internet
Author: User

iOS system provides command-line compilation tool under development environment: Xcodebuild "3"

Xcodebuild

Before introducing Xcodebuild, you need to figure out some of the concepts of "4" in the Xcode environment:

    • Workspace: Simply put, Workspace is a container where you can store multiple Xcode projects that you create, as well as other files that you need to use in your project.

The benefits of using workspace are:

1), expand the visual field of the project, that is, you can jump between multiple projects, refactoring, one project can use the output of another project. Workspace will be responsible for providing various interdependent relationships between project;

2), share the build directory between multiple projects.

    • Project: A project that is responsible for managing all the files and configurations that generate one or more software products, and a project can contain multiple target.
    • Target: A target is a product built in a project that contains all the files that build the product, and how to build the configuration for that product.
    • Scheme: A target that defines the build process becomes a scheme. The build process for target that can be defined in scheme is: build/run/test/profile/analyze/archive
    • Buildsetting: Configure the build settings for the product, for example, which architectures to use? Which version of the SDK is used?. In Xcode project, there is a project-level build Setting and a target-level build Setting. Build a product must be for a target, therefore, Xcode always prefer the target's build Setting, if target is not configured, then the project's build Setting will be used.

After figuring out these concepts, xcodebuild is well understood, and the official web site describes its role as follows:

Xcodebuild builds one or more targets contained in an Xcode project, or builds a scheme contained in an Xcode workspace or Xcode Project.

Xcodebuild is a command-line tool for building a product, and its usage can be summed up in 3 parts:

    • Objects that can be built
    • Build behavior
    • Some of the other auxiliary commands

Objects that can be built have, by default, run the first target under project:

    • Workspace: Must be used in conjunction with "-scheme" to construct a scheme under this workspace.
    • Project: When you have more than one project in the root directory, you must use "-project" to specify project and then run
    • Target: Build a target
    • Scheme: Used with "-workspace" to specify the scheme of construction.
    • ......

Build behaviors include:

    • Clean: Clears the build directory
    • Build: Building
    • Test: Testing a scheme that must be used with "-scheme"
    • Archive: Packaged, must be used with "-scheme"
    • ......

Auxiliary commands include:

    • -SDK: Specifying the SDK used by the build
    • -list: Lists all target and scheme under the current project.
    • -version: Version Information
    • ......

For more detailed command lines on xcodebuild see: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/ Xcodebuild.1.html

Is the result of running a scheme build using Xcodebuild:

After understanding the usage of xcodebuild, we then analyze the main defects of Xcodebuild:

    • From the sense of direct can get, its script output is very poor readability,
    • You can only run a target or scheme completely, or none of them will run. You cannot specify a specific test to run in target.
    • The most heinous is that the xcodebuild in XCode 4 actually does not support Iosunittest's target "5", and when I try to run a test target for an iOS app, I get the following error:

For the flaws mentioned above, Facebook gives them a solution: Xctool:

Xctool

Xctool on its homepage directly indicates its purpose:

Xctool is a replacement for Apple's xcodebuild that makes it easier to build and test IOS and MAC products. It ' s especially helpful for continuous integration.

Its role is to replace Xcodebuild, which is designed to make building and testing easier and better supported for continuous integration. From a personal point of view, it did succeed in replacing Xcodebuild. But xctool in the end is only a package for the Xcodebuild, but provides a richer build instruction, so the premise of using Xctool is that Xcodebuild already exists and works correctly.

Installation

Xctool installation is very simple, only need to clone Xctool repository to the project root directory can be used, if you have homebrew installed on your machine, can be installed through the "Brew install Xctool" command directly. (Note: Be sure to first confirm that the Xcodebuild is installed and works correctly before using Xctool.)

Usage

The use of Xctool is more humane, and can almost be reused for all xcodebuild instructions, configurations. Just a few points to note:

    • Xctool does not support target build, but only scheme builds.
    • The "-only" command is supported to run the specified test.
    • Support for build reports in multiple formats.

Example:

Path/to/xctool.sh-workspace   yourworkspace.xcworkspace   -scheme   yourschemetest-only SomeTestTarget: Sometestclass/testsomemethod

Is the effect that I ran test with Xctool:

Problems:

No architectures to compile for (Only_active_arch=yes, ACTIVE arch=x86_64, Valid_archs=armv7 armv7s).

Workaround: In Project setting, set "Build Active Architecture only" to No

Code sign error:a Valid provisioning profiles matching the application ' s Identifier ' dk.muncken.MyApp ' could not being found

Workaround: Specify the SDK through "-sdkiphonesimulator" to enable the use of application Identifier that conform to iOS conventions.

iOS system provides command-line compilation tool under development environment: Xcodebuild

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.