Automatic swift SDK updates in Mac OS

Posted in software by Christopher R. Wirz on Mon Jun 16 2014



Mac OS provides a scripting environment within the terminal to automate tasks such as downloading the latest SDK and updating it. The script discussed in this post demonstrates downloading the latest Swift SDK from a developer and entering your API key.

Note: Repleace https://<domain>.com//<path-to-file>.swift with the URL to your SDK in the following example
"<please request an API key>" is the string in the file where your API key will be placed

Create get_sdk.sh


#!/bin/bash
echo starting…
OLD="<please request an API key>"
echo we will replace $OLD
NEW=sampleap-ikey-prov-ided-bydevelopers
echo with $NEW
CWD=$(pwd)
echo $CWD is the current directory
FILE=$CWD/<file-name>.swift
echo $FILE is the file needing replacement
curl -O https://<domain>.com//<path-to-file>/<file-name>.swift
sed -i '' "s/$OLD/$NEW/g" $FILE

Now you can run the file by typing

	sh get_sdk.sh
Looking for a job?