kodeco.com Forums

Test Driven Development Tutorial for iOS: Getting Started

In this Test Driven Development Tutorial, you will learn the basics of TDD and how to be effective at it as an iOS developer.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5522-test-driven-development-tutorial-for-ios-getting-started

Hi @cabernathy,
Congratulations on this tutorial, I have a lot of devs ask (in-person) how to start with TDD and questions related to that, this article helps point them in that direction. It was long time coming, but finally it is here and quite well presented.



1 Like

Thank you for the tutorial @cabernathy, very well done and great for those wanting to start with TDD.

Just one observation: I prefer to use -= to decrease the variable value, for example: localNumber -= 9 instead of: localNumber = localNumber - 9. I feel like it makes it more evident.

I’m interested in working through this tutorial, @cabernathy, but when opening the starter project, I get this error in line 41 of Shuffle.swift:

let i = index(firstUnshuffled, offsetBy: d)
Cannot invoke ‘index’ with an argument list of type ‘(Self.Index, offsetBy: Int)’

It seems that offset needs to specifically be a SignedInteger, and I’ve noticed that hard-coding integers into the offset value will compile, but for some reason the Int d will not work (I’m on Xcode 9.2).

The source for this code can be found here. That may help you debug what’s going on based on the current Swift version you’re using. I’m on Xcode 9.4 and was able to get rid of errors by changing this line in Shuffle.swift:

let d: Int = numericCast(arc4random_uniform(numericCast(unshuffledCount)))

I didn’t see the error you’re getting. That’s weird. Let me know if you still see an issue. Also did you simply open the starter project or did you also do anything else like update the project based on any Xcode prompts.

I upgraded to Xcode 9.4.1 and was able to work through the entire tutorial without any problems! Thank you.

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!