Skip to content

Instantly share code, notes, and snippets.

@timburks
Last active April 10, 2017 18:49
Show Gist options
  • Save timburks/836c2ccf78ec770554b152d143ea5644 to your computer and use it in GitHub Desktop.
Save timburks/836c2ccf78ec770554b152d143ea5644 to your computer and use it in GitHub Desktop.
Run Swift on Google Cloud Shell! Here are some instructions for generating a Swift client and server for a gRPC API.
# Run gRPC and Swift in Cloud Shell
# First use apt-get to install packages needed to run Swift
sudo apt-get update
sudo apt-get install -y clang clang-3.8 lldb-3.8 libicu-dev libtool libcurl4-openssl-dev libbsd-dev build-essential libssl-dev uuid-dev curl unzip
# Next create a ~/local directory for some tools that we'll download
cd
mkdir -p local
# Add $HOME/local/bin to your path by adding the following to your .bashrc
# export PATH=.:$HOME/local/bin:$PATH
# After you've done the above step, reload .bashrc
source ~/.bashrc
# Download and install Swift in ~/local
SWIFT_BRANCH=swift-3.0.2-release
SWIFT_VERSION=swift-3.0.2-RELEASE
SWIFT_PLATFORM=ubuntu14.04
SWIFT_URL=https://swift.org/builds/$SWIFT_BRANCH/$(echo "$SWIFT_PLATFORM" | tr -d .)/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM.tar.gz
echo $SWIFT_URL
curl -fSsL $SWIFT_URL -o swift.tar.gz
tar -xzf swift.tar.gz --strip-components=2 --directory=local
# Download and install the protocol buffer compiler in ~/local
PROTOC_URL=https://github.com/google/protobuf/releases/download/v3.2.0rc2/protoc-3.2.0rc2-linux-x86_64.zip
echo $PROTOC_URL
curl -fSsL $PROTOC_URL -o protoc.zip
unzip protoc.zip -d local
# Download the grpc-swift repository
git clone https://github.com/grpc/grpc-swift
# Build the Echo example
cd grpc-swift/Examples/Echo/PackageManager
make
# Start the Echo server
.build/debug/Echo serve &
# Test the server with the Echo client
.build/debug/Echo get
.build/debug/Echo expand
.build/debug/Echo collect
.build/debug/Echo update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment