0%

Xcode Toolchain

xcode-select

This will install the Command Line Tools, which are necessary for compiling Objective-C code.

xcode-select install
    

xcrun

xcrun is the fundamental Xcode command line tool. With it, all other tools are invoked.

xcrun xcodebuild

In addition to running commands, xcrun can find binaries and show the path to an SDK:

xcrun --find clang
xcrun --sdk iphoneos --find pngcrush
xcrun --sdk macosx --show-sdk-path

Because xcrun executes in the context of the active Xcode version (as set by xcode-select), it is easy to have multiple versions of the Xcode toolchain co-exist on a single system.

Using xcrun in scripts and other external tools has the advantage of ensuring consistency across different environments. For example, Xcode ships with a custom distribution of Git. By invoking $ xcrun git rather than just $ git, a build system can guarantee that the correct distribution is run.

xcodebuild

Without passing any build settings, xcodebuild defaults to the scheme and configuration most recently used by Xcode.app:

However, everything from scheme, targets, configuration, destination, SDK, and derived data location can be configured:

xcodebuild -workspace NSHipster.xcworkspace -scheme "NSHipster"

There are six build actions that can be invoked in sequence:

build analyze archive archive installsrc install clean

genstrings

The genstrings utility generates a .strings file from the specified C or Objective-C source files. A .strings file is used for localizing an application in different locales, as described under “Internationalization” in Apple’s Cocoa Core Competencies.

genstrings -a \ /path/to/source/files/*.m

For each use of the NSLocalizedString macro in a source file, genstrings will append the key and comment into the target file. It’s up to the developer to then create a copy of that file for each targeted locale and have that file translated.

fr.lproj/Localizable.strings

1
2
3
4
5
6
/* No comment provided by engineer. */
"Username"="nom d'utilisateur";

/* {User First Name}'s Profile */
"%@'s Profile"="profil de %1$@";

ibtool

iprofiler

iprofiler measure an app’s performance without launching Instruments.app:

iprofiler -allocations -leaks -T 15s -o perf -a NSHipster

xed

This command simply opens Xcode.

xed NSHipster.xcworkspace

agvtool

agvtool can be used to version Xcode projects, by reading and writing the appropriate values in the Info.plist file.

摘录说明

摘录自《CFHipsterRef-Low-Level Programming on iOS & OS X》

中文参考: https://www.jianshu.com/p/2a351587f0ef