April 2017
swift method dispatch

A very good explanation can be found here. Here is a summary.

Direct Table Message
NSObject @nonobjc or final Initial Declaration Extensions, dynamic
Class Extensions, final Initial Declaration dynamic
Protocol Extensions Initial Declaration @objc Declarations
Value Type All Methods n/a n/a
August 2016
Finally Dipping my Toes in Swift

Swift is getting there. The language is maturing by day. The community is incredible. With version 3 coming, I think it is time to dip my toes in it.

The Experience

The language feels extremely elegant in my opinion. I agree most of the decisions made by the designer of the language. Which makes it very easy for me to learn. Took me an hour to get the big picture through Getting Started with Swift - WWDC 2016, which by the way, is a good starting point for anyone with background of other programming languages. And roughly another hour to play with it in Xcode. Then I started to write real code.

Dependency Manager

A good dependency management system is essential for any project. After digging around, I found that cocoapods is the established solution for that. However, I found Carthage/Carthage is the new black now. Also personally I like Carthage’s design philosophy better. I followed Creating your first iOS Framework from thoughtbot to setup my own framework project.

September 2016
Don't be an Agile Fanatic

Agile is not for everyone.

Take our team for example. We have 5 people, one of them is a team lead. We basically are 5 DRIs (Direct Responsible Individual) of some projects. But it doesn’t mean we don’t need to talk to each other. We talk to each other constantly because we sit next to each other. We just don’t need to collaborate very closely like normal development teams. By the way, a well designed architecture do a whole lot of more communication for itself. I found that it is efficient enough for us to understand the situation over all. Of cause we still need a meeting where we all sit together to clear some confusions occasionally, especially when there is a big change upstream that will alter our original roadmap. But that doesn’t happen every week, or month, and it shouldn’t. (If it does, we have a more serious issue to deal with.) We do iterate, but we iterate in our own pace. There isn’t a weekly/fortnightly meeting sitting in our calendars. IMO, we are agile in our way. It all comes down to communication. My point is: Agile methodology is nothing more than a collection of Good Ideas, you can pick some of them that apply to your team, just don’t build a religion around it.

April 2016
Detail Matters

Whenever some friends who just converted to Mac from Windows ask me questions like: Where is the start menu? How to I open “my computer”? Hey, I downloaded the app, I double clicked it, and it just open, how do I install it? I feel sorry for them. It is just so sad.

Recently I got into debate with one of my colleague, about a minor design difference between Windows and OS X. On Windows, you can right click anywhere, desktop, or a folder within file explorer, and select “new file” in the menu to create a text file, then you can give it a name, then you got an empty file with 0 bytes. Then you can double click to open it with a text editor start working on it. You can’t do it on OS X. It sounds like a good feature, or at least a convenient shortcut to quickly create a file. But really think about it, what do you need an empty file for? Your next action after you created the file is always going to be opening it with a text editor. So let’s count: find the place -> right click -> left click on new file -> type in file name -> hit enter to confirm -> double click the file (assuming you have the right file type association, otherwise you have to: right click the file -> open with -> sublime text). So at least 6 steps to create and open an empty file in a particular place. Yeah! What about: open the text editor -> start typing -> save with name and location. So 3 steps to create a file and write the content into it and save it in a particular place. So I would take that menu option out if I was making the decision.

April 2017
cross-platform swift

After reading this, I am deeply worried. It involves lots off fiddly to make it work. However, after swift 3.x (I don’t know which one was it), we have a better swift package generate-xcodeproj command which does lots of the fiddly for you. It worked, almost, until I try to run unit tests for a different platform, say iPhone. The problem is here.

I’m no stranger to these sorts of problems, fortunately, (sadly); the problem manifests because iOS and macOS have different test-bundle layouts, so your framework will be placed in different places in each, thus you have to tell your tests to look in different places for each. The easiest way is just to set the test rpaths to:

From Multiplatform Single Scheme Xcode Projects·PromiseKit.

So here is what you do.

  • Go to Build Settings of your test target. Search for run. You will see Runpath Search Paths.
  • Add, under both Debug and Release, Any OS X SDK. Set the value to @loader_path/../Frameworks. (it was @loader_path/Frameworks originally.)
  • You are ready to go.
May 2016
About Notes

It took me sometime to realise that I am not a writer, yet. I am struggling with converting my thoughts into a cohesive article. I believe the reasons behind this are:

  • I don’t have large block of time to process the thoughts, polish them, and write a long form article around it.
  • Different ideas come and goes, but very small, and very different.
  • English is not my native language.

So I decided not to wait for them to be crafted into articles before publishing them. Instead, I will just share the short notes directly, like this one. When time comes, I can still connecting the dots and make it complete.