Categories
Blog Code

Aztec: A native HTML editor

One of the most important aspects of the WordPress app is the post editor, after all the content generated by our users is what make their site different from all the others.

Since we started developing the WordPress apps, we wanted to provide the best writing experience to our users, writing is already hard by itself so you don’t need that the tool you are using to write to be complex, slow, or error prone.

Last August my team at Automattic started a project called Aztec, the ambitious goal was to have HTML editor that could support the same feature set has our web editor but completely written in native code.

After some hard working months, we are now releasing the first beta version of the editor in our native apps. If you want to know more you can read the official release post here and for the more technical inclined an architecture overview is available here. You can also check our open source code on our Github repo.

Remember this is not limited to be used on the WordPress apps, you can use it in any app that needs an HTML editor.

Pull Requests are welcome!

Categories
Blog Code

Font Metrics update

I developed FontMetrics some years ago when I was working for several publishing clients. Clients in publishing normally want to use their own brand fonts and have precise requirements regarding layout and text alignments.

This was a bit tricky to do with the iOS text system at the time, so I developed this app to allow to preview fonts and check their different metrics. This allowed the design team to do quick checks on the fonts files provided by the client and to quickly find the metrics to use for layouts.

This week I finally got some free time so I decided to have a look what needed to be done to bring it up to iOS 10. The last time I updated this app was when iOS 7 was launched, so it really needed some TLC!

This was implemented way before Swift was a thing so all of the app was written in Objective-C, and when I started to look at the code I found a lot of small issues and some really bad code.

It’s very humbling to look at code that you developed some years ago, it really makes you understand that you are always learning and you can always improve.

The app was so simple that I decided to update all code to Swift and do some much needed updates to the UI/UX.

I’m pretty happy with the end result so I decided to make the app open source and publish the repo on GitHub, bug reports and PRs are welcome!

Categories
Blog Code

Quicker Unit Test in iOS

Today while reviewing a PR on the WordPress iOS app just found about this very interesting technique to make iOS unit tests run quicker and more contained.

Simple and very efficient.

 

Categories
Blog Code

Logging in Swift

Here is my poor man version of logging for SWIFT

func logPrint(logMessage: Any, _ file: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
    print("\(file):\(line):0: \(function): \(logMessage)")
}

This method besides printing your message it shows the file name, the line and the function method where the log was made. The file, function and line numbers are extracted using literal expressions.

This makes it easier to find where the log message come from and if you have the KZLinkedConsole plugin installed in Xcode you just need to click on the error message in the console and Xcode will take you there.

For a more advanced logging library I recommend XCGLogger

== Update (2016-01-25) ==

I found out that the print statement doesn’t print to the System Logs, this could be useful in scenarios that you want to see the log message on a user device. So I update my method to use the NSLog function

func logPrint(logMessage: Any, _ file: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
    NSLog("\(file):\(line):0: \(function): \(logMessage)")
}
Categories
Blog Code

DVR

I really like DVR approach to networking testing. So much better than mocking.