CFHipsterRef Low-Level Programming on iOS & Mac OS X

Xcode Toolchain

Xcode Tools

  1. xcode-select

     xcode-select install
    

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

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

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

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

     /* No comment provided by engineer. */
     "Username"="nom d'utilisateur";
    
     /* {User First Name}'s Profile */
     "%@'s Profile"="profil de %1$@";
    
  5. ibtool

  6. iprofiler

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

     iprofiler -allocations -leaks -T 15s -o perf -a NSHipster
    
  7. xed

    This command simply opens Xcode.

     xed NSHipster.xcworkspace
    
  8. agvtool

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

Compilation & Assembly

  • clang: Compiles C, C, Objective-C, and Objective-C source files.
  • lldb: Debugs C, C, Objective-C, and Objective-C programs
  • nasm: Assembles files.
  • ndisasm: Disassembles files.
  • symbols: Displays symbol information about a file or process.
  • strip: Removes or modifies the symbol table attached to the output of the assembler and link editor.
  • atos: Converts numeric addresses to symbols of binary images or processes.

Processors

  • unifdef: Removes conditional #ifdef macros from code.
  • ifnames: Finds conditionals in C++ files.

Libraries

  • ld: Combines object files and libraries into a single file.
  • otool: Displays specified parts of object files or libraries. * ar: Creates and maintains library archives.
  • libtool: Creates a library for use with the link editor, ld. ranlib: Updates the table of contents of archive libraries. mksdk: Makes and updates SDKs.
  • lorder: Lists dependencies for object files.

Scripting

  • sdef: Scripting definition extractor.
  • sdp: Scripting definition processor.
  • desdp: Scripting definition generator.
  • amlint: Checks Automator actions for problems. Packages
  • installer: Installs OS X packages.
  • pkgutil: Reads and manipulates OS X packages. * lsbom: List contents of a bom (Bill of Materials).

Documentation

  • headerdoc: Processes header documentation.
  • gatherheaderdoc: Compiles and links headerdoc output.
  • headerdoc2html: Generates HTML from headerdoc output.
  • hdxml2manxml: Translates from headerdoc XML output to a file for use with xml2man
  • xml2man: Converts Man Page Generation Language (MPGL) XML files into manual pages. Core Data
  • momc: Compiles Managed Object Model (.mom) files
  • mapc: Compiles Core Data Mapping Model (.xcmappingmodel) files