Building Ice Applications in Swift

This page provides important information for Swift developers.

On this page:

Prerequisites

In order to build applications with Ice in Swift, you need:

  1. The Slice to Swift compiler 
    slice2swift is a command-line tool written in C++. You need it only during development. You can install slice2swift with:

    brew install ice
  2. The Ice Framework for Swift Package Manager

    Add Ice and PromiseKit repositories to your package descriptor dependencies:

    dependencies: [
        .package(url: "https://github.com/mxcl/PromiseKit.git", from: "6.10.0"),
        .package(url: "https://github.com/zeroc-ice/ice-spm.git", "3.7.10" ..< "3.8.0")
    ],

    The following modules are available from Ice package:

    • Ice
    • IceGrid
    • IceStorm
    • Glacier2

    The PromiseKit package provides the PromiseKit module.

    Ice and PromiseKit modules are the minimum requirements for using Ice for Swift.

Compile Slice Files

Ice for Swift 3.7 does not compiling Slice files with Swift Package Manager. You have to manually compile your Slice definitions using the slice2swift compiler, and add the generated source files to your package sources directory.

Adding Ice Frameworks

In the package descriptor add the Ice and PromiseKit frameworks as dependencies to your targets:

targets: [
    .target(name: "Client", dependencies: ["Ice", "PromiseKit"]),
    .target(name: "Server", dependencies: ["Ice", "PromiseKit"])
]

There are additional modules for Glacier2, IceStorm, and IceGrid.

PromiseKit

The Ice API for asynchronous invocations and dispatches relies on promises provided by PromiseKit. As a result, you need to bundle the PromiseKit framework in addition to the Ice framework with your Ice-based applications.

Using the Sample Programs

Sample programs are available at the ice-demos GitHub repository. You can browse this repository to see build and usage instructions for all supported programming languages. You can clone this repository with:

git clone -b 3.7 https://github.com/zeroc-ice/ice-demos.git
cd ice-demos