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:
The Slice to Swift compiler
slice2swiftis a command-line tool written in C++. You need it only during development. You can installslice2swiftwith:brew install ice
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:
IceIceGridIceStormGlacier2
The PromiseKit package provides the PromiseKit module.IceandPromiseKit modulesare 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