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!

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!

A New WordPress App Update, Designed for the iPad

A great update on our WordPress app. News

Over the past few months we’ve been working to dramatically improve users’ experience on iPad — and we’re proud to share those with you now, in our WordPress app for iOS, available in the iTunes Store.


The apps were originally designed with only iPhones in mind, so we wanted to make better use of the space available on the iPad and especially iPad Pro, to maximize your productivity in the app. These changes shipped incrementally, with the very final ones being included in the 7.1 release that went out last week.

We’ve improved the My Sites management to make it easier to handle multiple sites on iPad. Now you can see the posts from that blog alongside the list of blogs, and site management is now all on one screen – no more back and forth!


Managing profiles follows the same pattern.


Notifications has been overhauled, too.


We’re really…

View original post 34 more words

Last year Automattic, the company that I work for, bought the .blog domain  and being a generous company they decided to offer to all automatticians  the domain of their choice!

So say hello to my new domain: !!

So from now on I will start using this new home for my personal writing:  travel, review of co-work places, day to day events, music, books and rants.

I will keep going on but now more focused on my professional achievements, conferences and code projects.

Automattic GM 2016 – Whistler

This year the Automattic Grand Meetup was in Whistler village. The Grand Meetup is an annual event where all workers of Automattic meet in a single place, do new friendships renew some old ones, have fun together and plan the year ahead.
The week started with a big town hall where Matt Mullenweg (our CEO) answer all the questions, it lasted until 2 am. Then for the rest of the week we split into groups doing workshops, projects, and classes. The last two days were dedicated to fun activities: trekking, escape rooms, downhill bikes, beer festival, photo tours, zipline and others. It all finished with a bang with a big party on the last night, even a bear showed up!



Try Swift! NYC

This year I had the opportunity to attend Try Swift! NYC, a conference dedicated 100% to Swift development.

This is a fairly new conference, the first edition was back in March in Tokyo, but the organization level was excellent. From the initial website, the registration process, pre-conference events, the conference itself all was great.
It all started with a pre-meetup party on the Meetup headquarters in NY, the nice folks of Meetup did a quick introduction and talked about their new app, 100% made in Swift, and then send us to a rooftop dinner and drinks!!!

Next day the event itself was in the Axa Event and Production Center in downtown Manhattan , this was a one track event and it all happened on a good sized auditorium, all very comfortable and with excellent audio/video resources. The presentations and  speaker were of high quality and they ranged from beginner to advanced topics.

My favorite presentations were:

  • Random Talk: the Consistent World of Noise, excellent talk from Natalia Berdis about random algorithms and how to use it. Excellent  slides to show how different random algorithms works and when to use them.
  • Lambda: There and Back Again, from Rob Napier simple down to earth presentation on how to use functional programming in Swift.
  • Incremental Swift , Amy Dier talks on how Etsy is using Swift in their codebase. Very interesting to learn they try to keep everything done in Swift still easy accessible from Objective-C code.
  • Making rich text editor in Swift, Katsumi Kishikawa with a very detailed talk about all the things you need to be aware when working with text in iOS. I learned this the hard way some year ago when doing the Aljazeera app.

Besides the presentations/speakers, the great thing about the conference was the community that was present, everyone was super friendly and always available for a chat. The speakers themselves were super friendly and made time during their time there to answer any question that you could have, in fact after they did their presentation they were available for an hour to answer questions.

The organizers themselves had super attention to detail, they provided every morning a set of basic toiletries, in case you had forgot something while packing. They had a magician as a break entertrainer to keep people energized between presentations. Of course good coffee was always available and the meals provided where not bad at all.

The only hiccup of the conference was the Pizza and Party event of the first night, it was a bit disorganized and the pizza took forever! Quickly sorted out by going out to local Pizzaria recommended by NY local.

Definitely going back next year! Keep up the good work Natasha the Robot!

Crashes on iOS 10

I spent the last week watching Apple WWDC videos, and after downloading Xcode 8 I was testing several of my libraries and applications.

While testing the WPMediaPicker library I found that the sample app was crashing every time I opened the picker. After some investing on the code I found that the app was crashing the moment I was trying to use the PHPhotoLibrary class.

After some looking around in the documentation I found out this:

Important: To protect user privacy, an iOS app linked on or after iOS 10.0, and which accesses the user’s photo library, must statically declare the intent to do so. Include the NSPhotoLibraryUsageDescription key in your app’s Info.plist file and provide a purpose string for this key. If your app attempts to access the user’s photo library without a corresponding purpose string, your app exits.

Before iOS 9 if you tried to access the Photo Library without providing this key you will simple get a default warning but now it simple crashes the app.

And this isn’t limited to the Photo Library, this is now standard behaviour to all the libraries that need to have an UsageDescription key on the Info.plist file.

Here is a small compilation:

  • NSAppleMusicUsageDescription

  • NSBluetoothPeripheralUsageDescription

  • NSCalendarsUsageDescription

  • NSCameraUsageDescription

  • NSContactsUsageDescription

  • NSHealthShareUsageDescription

  • NSHomeKitUsageDescription

  • NSLocationAlwaysUsageDescription

  • NSLocationWhenInUseUsageDescription

  • NSMicrophoneUsageDescription

  • NSMotionUsageDescription

  • NSPhotoLibraryUsageDescription

You can find the full list here, just search for UsageDescription on the page.

If you still are not using these keys is time to start to update your applications and use this opportunity to provide a good text for your requests for permissions from  your app users.

JSON Deserialization in Swift

Some time ago when Swift was announced there was a big discussion in the iOS development community about JSON deserialisation and the right way to implement it. At the time, I didn’t give it much attention because I was still committed to Objective-C and didn’t have any immediate requirements to use Swift.

Fast forward two years and I’m now mostly programming in Swift and quickly found out the issues around JSON that everyone was talking about two years ago.

The main problems result from the way JSON parsing is done on iOS, the NSJSONSerialization object simply returns an AnyObject for you to handle, and because of Swift is very strictly typed you soon get code that is very verbose and hard to follow.

For example to read the photo URL from a JSON file like this:

    "id": 1,
    "name": "Sergio",
    "weight": 70.5,
    "photos": [{
             "url": "",
             "width": 100,
             "height": 200

You will need to write something like this:

do {
    guard let url = NSBundle.mainBundle().URLForResource("sample", withExtension: "json"),
        let JSONData = NSData(contentsOfURL: url),
        let users = try NSJSONSerialization.JSONObjectWithData(JSONData, options: NSJSONReadingOptions()) as? Array<AnyObject>
        let user = users[0] as? [String: AnyObject],
        let photos = user["photos"] as? Array<AnyObject>,
        let photo = photos[0] as? [String: AnyObject],
        let photoURL = photo["url"]
    else {
        print("Ops... some error")
} catch {

While this is improved from early versions of Swift because of the addition of the guard statement and the new error handling, it’s still very verbose and if you need to track errors on the JSON file you need to split all the guard conditions in order to be able to find where things failed.

So I decided to implement my own library to allow less verbose code while reading values from JSON, but without using any custom operators or protocols like other libraries. Another goal was also to make it easy to find any mistakes made on the JSON files.

The end result was a single class called SVEJSONObject were you can write code like this:

    let url = NSBundle.mainBundle().URLForResource("sample", withExtension: "json")!

    do {
        let users = try JSONObject(url: url)
        let photoURL = try users[0]["photos"][0]["url"].string()
    } catch {

SVEJSONObject allows you to have simpler deserialization code by keeping types restricted to what is available in the JSON specification.

It also allows you to chain subscript calls like this:


And it makes error tracking easy by using Swift exception mechanism with a custom ErrorType that shows what went wrong. For example, if for some reason you tried to do this


you will get an JSONValidationError with this message:

Root[0]->photos->[0]: Missing "link" element in dictionary.

You can check the full code and documentation in the project repo in GitHub.