Testing in Swift

Posted on Sun 10 June 2018 in Swift • Tagged with swift

We want to be able to write tests in Swift, and to do this we will use the XCTest framework.

We'll start by writing a function to test, something we haven't actually done yet.

(All the code here is available from [Github](

// add-function.swift  [Swift 4.1, Xcode ...
Continue reading

Synchronous HTTP GET in Swift

Posted on Sat 09 June 2018 in Swift • Tagged with swift

In the last few posts, we've seen how to print, get arguments from the command line, and how to get lines of keyboard input and implement a REPL (read, evaluate, print loop).

The particular command-line tools I want to build are for interacting with MicroDB, an online distributed tag-based ...

Continue reading

A Simple REPL (Read, Evaluate, Print Loop) in Swift

Posted on Sun 03 June 2018 in Swift • Tagged with swift

We looked in the last post at how to get arguments from the command line. We will also be interested in how to build a REPL---a Read, Evaluate, Print Loop that reads input from the keyboard and responds until some exit condition is met, and then exits. program is often ...

Continue reading

Command-Line Arguments (argv and argc) in Swift

Posted on Sun 03 June 2018 in Swift • Tagged with swift

There are two main styles of command-line tool. One of them takes its inputs on the command line, does something, and exits. The other starts, reads input from the keyboard and responds until some exit condition is met, and then exits. This second style of program is often called a ...

Continue reading

Hello, World in Swift

Posted on Sun 03 June 2018 in Swift • Tagged with swift

Of course, we start with printing. Here is "Hello, World!" in Swift. It couldn't be much simpler.

// hello.swift  [Swift 4.1; Xcode 9.3.1; 2018-05-27]
//
// Just say "Hello".
//

print("Hello, World!")

The //, of course, introduce comments, print is the print function, and "Hello, World!" is the string ...

Continue reading

Command-Line Interfaces in Swift

Posted on Sun 03 June 2018 in Swift • Tagged with swift

This is a new blog about my journey learning Swift by writing command-line tools (in fact, probably just one or two command line tools). I'm writing it mostly as reference for myself, but also in the hope that it might help someone else.

It is Sunday 3rd June 2018 ...

Continue reading