Shell script to compile Slice files to C++ or Objective-C in Xcode
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Ice Builder for Xcode

Ice Builder for Xcode is a command line program to help compile Slice files to C++ or Objective-C in Xcode. It supports all recent versions of Xcode.



Install Ice Builder for Xcode using Homebrew by running the following commands:

brew install zeroc-ice/tap/ice-builder-xcode


Download the icebuilder shell script to any path on your system. For example: /usr/local/bin/icebuilder.



Option Description
--ice-home HOME Set the Ice home directory.
--cpp Use slice2cpp instead of slice2objc.
-h, --help Print usage message.
-v, --version Display the version of Ice Builder.
-- ARGS Arguments passed directly to the Slice compiler.

If you do not set the Ice home directory with --ice-home, the builder first scans the Additional SDKs of your project, and attempts to find its Ice home in SDKs with IceTouch or IceSDK in their path.

If there is no such SDK, the builder uses /usr/local as its Ice home directory.

Refer to the slice2cpp and slice2objc Command Line Options documentation for a description of the options you can provide through ARGS. You could for example invoke the builder with:

icebuilder --cpp -- -DFOO=1 --checksum

The builder automatically adds the following include directories to the Slice compilation:

  • the Ice Slice files directory provided by Ice home
  • the directory of the Slice file being compiled

Xcode Build Rule

To use Ice Builder for Xcode, you must create a custom build rule in your Xcode project. For example:

  • Process Source files with names matching: *.ice

  • Using Custom script:

    /usr/local/bin/icebuilder [options]
  • Output Files:

    • $(DERIVED_FILE_DIR)/$(INPUT_FILE_BASE).cpp (For a C++ project)
    • $(DERIVED_FILE_DIR)/$(INPUT_FILE_BASE).m (For an Objective-C project)

Xcode Custom Build Rule

The wildcard *.ice means Xcode will execute your custom script for each Slice file.

The Output Files must list exactly two files: the header file and the C++ or Objective-C implementation file generated by the Slice compiler. These two files must be in the same directory: the builder sets --output-dir to this directory when it calls the Slice compiler.

Xcode Build Settings

Refer to the release notes of your Ice or Ice Touch distribution:

Generating Code using Xcode

The builder will always compile a Slice file when executed by an Xcode custom build rule; however, Xcode custom build rules are only executed when either the given Output Files do not exist or are older than the file being processed. To force your Slice files to be re-compiled you need to clean (⇧⌘K) your project, then build (⌘B).