Swift 3 Compatible

I’ve been making a lot of improvements to the Clean Swift Xcode Templates, but it’s taking a lot longer than I anticipated. In the meantime, I’ve upgraded the templates to be compatible with the latest Xcode 8 and Swift 3. You can now get back to work with your latest toolchain, without having to manually fix the generated files. Enjoy!

You can download the updated templates using the same link in your previous email.

I’ll update the templates again when the new features are ready to ship. Stay tuned.

Continue reading →

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 Principle

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 →