Command line tools comes bundle with Xcode prior to 4.3 version. After 4.3, you need to install a separated command line tools yourself. First, go to this url. Search for 'command line tools' (in the search field on the left), then click on the latest version of 'Command Line Tools (OS X Mountain Lion) for Xcode,' and click on the the.dmg link to download it. Once the.dmg has finished downloading, double-click on it (if it didn't already open automatically).
Technical Note TN2339
This document provides answers to frequently asked questions about command line tools.
What is the Command Line Tools Package?
The Command Line Tools Package is a small self-contained package available for download separately from Xcode and that allows you to do command line development in macOS. It consists of the macOS SDK and command-line tools such as Clang, which are installed in the
/Library/Developer/CommandLineTools directory.
Downloading command-line tools is not available in Xcode for macOS 10.9. How can I install them on my machine?
In macOS 10.9 and later, the Downloads pane of Xcode Preferences does not support downloading command-line tools. Use any of the following methods to install command-line tools on your system:
Note: In macOS 10.9 and later, Software update notifies you when new versions of the command-line tools are available for update.
How can I uninstall the command-line tools?
I have multiple versions of Xcode installed on my machine. What version of Xcode do the command-line tools currently use?
To find out what version of Xcode is being used by your tools, run the following command in Terminal:
Listing 2 Printing the version of Xcode currently used by the command-line tools.
How do I select the default version of Xcode to use for my command-line tools?
To select a default Xcode for your command-line tools, run the following command in Terminal:
where <path/to/> is the path to the Xcode.app package you wish to use for development.
Listing 3 Setting the default Xcode version.
How do I build my projects from the command line?
xcodebuild is a command-line tool that allows you to perform build, query, analyze, test, and archive operations on your Xcode projects and workspaces from the command line. It operates on one or more targets contained in your project, or a scheme contained in your project or workspace. xcodebuild provides several options for performing these operations as seen its man page. xcodebuild saves the output of your commands in the locations defined in the Locations preferences pane of your Xcode application, by default.
See below for various xcodebuild usage. Be sure to navigate to the directory containing your project or workspace in Terminal before running any of the following commands.
My app has multiple build configurations. How do I set a default build configuration for xcodebuild?
In Xcode, the Configurations section of your project's Info pane provides a pop-up menu, which sets the default configuration to be used by xcodebuild when building a target. Use this pop-up menu to select a default build configuration for xcodebuild as seen in Figure 2.
How do I run unit tests from the command line?
xcodebuild provides several options for running unit tests.
To build and run unit tests from the command line, execute the following command in Terminal:
To build unit tests without running them from the command line, execute the following command in Terminal:
To run unit tests without building them from the command line, execute any of the following command in Terminal:
The test action requires specifying a scheme and a destination. See How do I implement the Build For Testing and Test Without Building features from the command line? for more information about build-for-testing and test-without-building actions.
The
-workspace option allows you to specify the name of your workspace. Use this option when your scheme is contained in an Xcode workspace.
The
-project option allows you to specify the name of your Xcode project. Use this option when your scheme is contained in an Xcode project. It is required when there are multiple Xcode projects in the same directory and optional, otherwise.
The
-destination option allows you to specify a destination for your unit tests. It takes an argument <destination-specifier> , which describes the device, simulator, or Mac to use as a destination. It consists of a set of comma-separated key=value pairs, which are dependent upon the the device, simulator, or Mac being used.
The
-only-testing and -skip-testing options, which are optional, allow you to run only a specific test and to skip a test, respectively. They take an argument <test-identifier> , which specifies the test to be executed or excluded. test-identifier 's format is as follows:
TestTarget , which is required, is the name of the test bundle. TestClass and TestMethod , which are both optional, respectively represent the name of the class and the name of the method to be tested.
Note: See Xcode Scheme and Run your app in Simulator for more information about scheme and destination, respectively. How to download mac os x lion 10.8 for free.
The
-destination option also allows you to run the same unit test on multiple destinations. This is done by adding it multiple times to your xcodebuild test command as demonstrated in Listing 17.
Listing 17 Tests the iOS scheme in both the Simulator and on an iPod touch.
Note: xcodebuild runs your tests sequentially. For instance In Listing 17, xcodebuild will first test iOS in the Simulator before executing it on the iPod touch.
How do I implement the Build For Testing and Test Without Building features from the command line?
Note:
build-for-testing and test-without-building provide support for continuous integration systems.
What keys can I pass to the exportOptionsPlist flag?
To get all available keys for
-exportOptionsPlist , run the following command in Terminal:
Os X Lion
Listing 22 Fetching all keys supported by -exportOptionsPlist.
See Figure 3 for a sample file that contains some options for the -exportOptionsPlist flag.
How do I archive and export my app for distribution?Xcode Command Line Tools Version
To archive and export your app for distribution, run the following command in Terminal:
where
<xcarchivepath> specifies the archive or the path of the archive to be exported, <destinationpath> specifies where to save the exported product, and <path> is the path to the file with a list of options for the -exportOptionsPlist flag.
Listing 23 Exports the iOSApp archive to the Release location with the options saved in the OptionsPlist.plist.
Document Revision History
Copyright © 2017 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2017-06-19
This blog post is for a very specific group of people who cared enough to notice that git command line tool is not working on their brand new MacBooks with Mountain Lion! If that sentence didn’t make sense to you, then you are probably at the wrong place. I got my new Mac last week and I wanted to clone some code from Github. So I opened the terminal to clone it and behold, “git” is apparently not a recognized command! I have already installed the latest developer preview of Xcode (version 4.6 DP3), so what went wrong here? It turns out that we need to manually install the git command line tools. We still live in a world where git is not an integral part of all the systems! Xcode 4.6 doesn’t install the command line tools by default, and Git is one of the tools included in these command line tools. Anyway, there’s a simple fix for it.
Using Macports
If you are still reading this, then I assume you would have already tried this method. But just for the sake of completeness, I will describe it. If you don’t have Macports installed, you can install it from here. Once you install it, open the terminal and type the following:
$ sudo port install git-core +svn +doc +bash_completion +gitweb
That should install git for you. Make sure your PATH environment variable contains the path to git. Follow these steps:
Open the terminal and try to git clone something. If that doesn’t work, then read on, there’s another method!
Using Xcode
If you are reading this section, then the above method probably didn’t work for you. You may also have tried a couple of other methods as well. If nothing has worked for you yet, the following steps definitely will. Make sure you have Xcode installed, and then do the following:
————————————————————————————————-
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |