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)")

Apple TV Tech Talks – London

I attended the Apple TV Tech Talks in London this week. They are part of a tour that developers and designers from Apple are doing around world to show the possibilities of the new Apple TV and share some insights on how to design and develop for it. 

The presentations where all very good with a lot of suggestions on how to optimise/improve your app in terms of UI/UX and tech. Even more valuable where the coding and UI/UX workshops where you could present your questions directly to an Apple engineer or designer. You could even get design review from one of the UX experts from Apple.

In conclusion it was great and concise conference about tvOS, in a way I think they are better than the WWDC because they are more focused and a lot less crowded! It was also a great opportunity to connect with London developers community and see some old colleagues. I hope they do them again next year!


WordCamp Edinburgh 2015

I had a great time on WordCamp Edinburgh 2015, met some great people from the local WordPress community and enjoyed some great talks from the other speakers.

Here is the video of my presentation about the WP-REST API

and the slides:

The code for the app  show in the presentation can be found on this GitHub repo.

I also participated on the Roundtable about the future of the REST API:

#wcedin @wcedin

WordPress iOS App

Role: Core Developer

Client: Automattic

Links: AppStore, GitHub repo

Inspiration strikes — anytime, anywhere. Manage your WordPress blog or website on the go, from your iOS device: view your stats, moderate comments, create and edit posts and pages, and upload media. All you need is a WordPress.com blog or a self-hosted WordPress.org site running 3.6 or higher. With WordPress for iOS, you have the power of publishing in the palm of your hand. Draft a spontaneous haiku on the train. Snap a photo on an afternoon stroll for the week’s photo challenge at The Daily Post. Respond to your latest comments, or monitor your stats to see where today’s readers are coming from.

Brew Lab

Great place to co-work in Edinburgh, excellent coffee (they even have cold brew!) great wifi connection, power plugs available all around, good music and excellent food!

The only downside is that it gets very busy so get there soon in day to grab a seat.


tvOS – How to start

If like me you got excited about the new tvOS platform that Apple launched last week, here are some mandatory documents to read before you start coding away:

While you read this you can download Xcode 7.1 beta that includes the tvOS SDK.

After you finish reading the documents I recommend download the UIKit Catalog for tvOS sample app and have a look around on the code to see how things are done on tvOS.

Have fun!