Understanding Hashable, Equatable, and Set Membership

July 1, 2018 | Swift, Protocols, Collections, iOS, macOS, tvOS, watchOS

The `Hashable` protocol in the Swift Standard Library allows us to use our own custom types as a key in a dictionary or as a member of a set. Conforming to `Hashable` where appropriate can make our code safer and improve performance. However, it's important to understand how `Hashable` and `Equatable` work together . . .

Observing Real-Time Ouput From Shell Commands In A Swift Script

June 27, 2018 | Swift, Unit Testing, Scripting, iOS, macOS, tvOS, watchOS

In the last tutorial, we saw how to generate code coverage reports using the new `xccov` tool. Part of that process is using the `xcodebuild` command to build a project with code coverage enabled. We ran that command directly in Terminal, but we could also run `xcodebuild` in a Swift script. The problem is `xcodebuild` takes time, and . . .

xccov: Generating Code Coverage Reports

June 21, 2018 | Swift, Unit Testing, Scripting, iOS, macOS, tvOS, watchOS

With the release of Xcode 9.3, Apple included a new command line tool called "xccov". It can be used to view code coverage reports as JSON, which can then be used to automate code coverage workflows. In this tutorial we'll see how to generate and view code coverage reports. We'll then write a Swift script to process the report.

Swift For Complete Beginners Part 3: Types

June 16, 2018 | Swift, Beginner

In Part 2 you learned how to declare constants and variables. When we declared `let pi = 3.14159` or `let email = "test@example.com"`, we didn't seem to care too much that one is a number (pi) and the other is text (an email address). However, you probably noticed that pi was declared without quotes while the email address was . . .

Swift For Complete Beginners Part 2: Constants and Variables

May 8, 2018 | Swift, Beginner

You've set up Xcode and wrote your first program, but you probably don't yet understand how the code you wrote works. That's OK, we'll get there! In this tutorial we'll learn about two of the basic building blocks of computer programs, constants and variables.