Swift 2 Unit Testing & UI Testing Resources

Starting to write unit tests in Swift 2 / Xcode 7 so thought I would keep a list of resources and share.  Plan to keep this post updated as I find more.  Feel free to ping additional resources in the comments!

 

Google Analytics & Swift

students of knowledge working on Apple hardware

I’m working on an iOS app written entirely in Swift that uses the Google Analytics library.  At Google I/O 2015 they announced full support for Swift and even CocoaPods (which doesn’t actually work if any of your other libraries use_frameworks! – but they are working on that and it’s not a trivial fix).  The initial intro documentation from Google has options to show the code sample in either Objective-C or Swift, but all the rest of the documentation still seems to be Objective-C, only.  I was listening to the More Than Just Code podcast tonight and Aaron Vegh was remarking on how going back to Swift code just wasn’t clicking, and he found it easier to just write stuff in Objective-C.  So I thought, hey, until Google updates their docs, why not list some Swift code samples for how to implement various things in Swift.

Here I just want to look at a simple task: Event tracking in Google Analytics.  Yes, this might seem trivial, but when you’re a developer switching back and forth between Objective-C and Swift, sometimes it’s nice if someone points out the syntax, as per Aaron’s comments.

Here’s the Objective-C code (adapted from the Google Docs, link above):

[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui action"
                                                      action:@"button press"
                                                       label:@"do something"
                                                       value:@1988] build]];

And here’s the Swift equivalent:

tracker.send(GAIDictionaryBuilder.createEventWithCategory("ui action", action: "button press", label: "do something", value: 1988).build() as [NSObject : AnyObject])

btw if anyone comes up with, or knows of, a nice plugin for WordPress to color code Swift appropriately, please let me know! 😛

 

Links:

core data & cloud services for iOS in Swift

As an iOS / Swift mentor for Thinkful.com, every week I give my students a list of resources as a follow up to our mentoring session.  This week’s resources cover details of dealing with data loaded from the Internet, storing data locally (core data and alternatives to core data), and cloud services.  Finally we wrap up with some photoshop tips to automatically create 1X, 2X, and 3X assets for your iOS projects.

 

this week’s iOS related resources

tools of the trade

This week’s resources relate to putting together your UI in Interface Builder – Auto Layout, Adaptive Layout, Size Classes, Dynamic Text, and mastering the Interface Builder IDE.  Additionally, we touched on architectural design patterns (MVC, MVVM, etc.).  Finally, most of my students are starting to struggle with networking via the AFNetworking library, and using Objective-C libraries (although none of them know any Objective-C) in their Swift apps using bridge headers. Continue reading “this week’s iOS related resources”

a different approach

Apple UX: Continuity

so microsoft’s strategy has been, ‘one OS for ALL devices’

Apple’s strategy is, ‘one, seamless, continuous experience across ALL devices’.

It might sound like a subtle difference at first glance, but it’s a universe of a difference.  Microsoft demands the user make the same OS work no matter what device you’re on, so we find folks griping about a touch interface on a non-touchscreen device etc.

The Apple user might start writing an email on his/her iPhone, then sit down at a computer and finish it there – the half composed email is magically there.  The UX fits the device, and there is continuity of the task itself.

The idiocy of technical interviews

Square Wheels

Some time ago I read this post, “I will not do your tech interview“.  It’s an awesome commentary and I agree with it wholeheartedly.  As a consultant, I have to do a lot of interviews, and many times it’s hard to know a lot about the company who is going to interview me, or their corporate culture, or what to expect, ahead of time.  Hence, for me interviews are a two-way street – I am as much interviewing my potential client, as they are interviewing me.  Today I had a particularly hilarious interview.  The interviewers started off the interview by telling me their names and then proceeding to read from a grocery list of academic text-book questions.  That alone made me do a double take, even though I had been warned this would be a ‘technical interview’.  What, you don’t want know jack about me?  How are going to know if I’m pleasant to work with, or what my personality is like?  If those things don’t matter to you, what kind of insane work environment do you guys have?

At the end of the interview, which was for a Flex project, I asked them, ‘so, are you guys using the latest Apache Flex build, or what version are you using?’.  One of the guys proceeded to give me another grocery list – this time of all the technologies they are using, from Ruby, to MySQL.  Hm.  Let’s try that again.  ‘WHAT VERSION OF FLEX ARE YOU ACTUALLY USING?’

He said, ‘oh we’re using the old (Adobe) one, because Apache Flex doesn’t support AIR’.

WOW.  Can you spell M-O-R-O-N?  Never mind, that Apache Flex has always supported AIR from day one, and that if it didn’t it would be like Microsoft not supporting Windows anymore.  Any monkey who bothered to even visit the Apache Flex web site would realize that.  So, what you’re telling me, is that at your company, where you’re building ‘enterprise level’ projects in Flex, nobody in your team has bothered to keep up with the current state of affairs of Flex itself, and you’ve made serious architectural decisions regarding your software based on some ridiculous assumptions?  Yeah, sign me up right away…NOT.