Clean Swift templates now updated for Xcode 8.3.3 & 9.0 and Swift 3 & 4

After many months of development and testing, experimenting with multiple projects, and initial beta testings by some of you, I have just released the Clean Swift templates to work for the latest Xcode 8.3.3 and 9.0. You can use it for Swift 3 and 4.

This update also has the following, long-awaited features:

I’ll be writing more about the new improvements in the coming weeks. In the meantime, you can check out the updated CleanStore sample app on GitHub to see how to use these latest templates.

A big thanks to those who tested early and provided me a long list of feedback and suggestions. I’ll read everything and see what I can push to the next update.

You can buy The Clean Swift Handbook with a free one-month access to my Slack team to get started with the latest templates, Xcode, and Swift.

Download the latest Clean Swift templates by subscribing below.

Seed data for your unit tests

As I added new scenes and wrote new unit tests for Clean Swift Xcode templates v2, creating test data manually becomes very tedious. There’s got to be a better way.

In the Rails-land, seed data for testing purpose is built right in to the framework. You can create all your test fixtures as YAML files in the fixtures folder. So you would create a file named fixtures/orders.yml and put your test orders there.

It’s time to have better support for test data in iOS.

A backward approach

When you want to create a test order, what do you want the syntax to look like? I think something like this will be nice:

Seeds.Orders.amy creates a test order for Amy (i.e. the order’s first name is Amy).

Very straightforward. So how can you design your test data so you can invoke it like that?

Continue reading →

Protocol Oriented Programming

There has been a lot of buzz ever since the 2015 WWDC talk on Protocol Oriented Programming. But the underlying principle has been around forever. Protocol is a feature provided by the programming language to facilitate polymorphism.

What is polymorphism?

There are many different kinds of polymorphisms as described in Wikipedia. I’ll focus on the kind that is the most important in Swift.

When I first learned about polymorphism in C++, it was at the function level. The goal is to avoid having to duplicate functions that take different types of parameters but do the same thing, making code reuse possible.

Duplication at the function level

Let’s take an example for a whirl.

Continue reading →

This is why most mobile development projects fail

You just signed a new client.

You are excited to work on this new project. It’s technically challenging and financially fulfilling. You’re going to do your absolute best to make this project a success for you and your client.

You’re hoping to build your reputation along the way by featuring this client in your portfolio. And they’re going to mention you in their press release for some word-of-mouth marketing.

Continue reading →