Parveen Kaler

Founder | Smartful Studios Inc.

CrashKit: Helping Your iOS/iPhone Apps Suck Less

First there was the iPhone and iPod Touch.  Then the iPad.  Then iOS 3.0.  Then 3.2 but iPad only.  Then 4.0 but some of the features aren’t available on older models.  Then there is the 4×3 versus 3×2 aspect ratio to worry about.  And then 480×320 versus 1024×768 versus 960×640.  The Media Player framework changes at every single point release.

All of this fragmentation means that iOS Apps crash.  CrashKit catches uncaught exceptions, traps signals, and sends them to developers by email or straight to your bug database.

Foursquare

Foursquare dumps a stack trace whenever it crashes.  It then asks the user to email the crash report to the developers the next time they launch the App.

The problem is that the user may not ever launch your App ever again.

Foursquare Crash

We can do better than this.

What CrashKit Does

CrashKit catches uncaught NSExceptions.
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
It also traps signals that the operating system sends when the App touches memory that doesn’t belong to it or executes illegal operations.

signal(SIGABRT, sighandler);
signal(SIGBUS, sighandler);
signal(SIGFPE, sighandler);
signal(SIGILL, sighandler);
signal(SIGPIPE, sighandler);
signal(SIGSEGV, sighandler);

The signal handlers unwind the stack frame and try to find out exactly where the crash happened.  This bug report can then be emailed or sent to FogBugz.

FogBugz

FogBugz exposes a BugzScout API that accepts bug reports using HTTP GET/POST methods.  It buckets similar bugs together and appends them to existing bug reports.

Pump That Run Loop

There are a number of subtle issues with catching and reporting crashes.  In general, UIKit is not re-entrant.  Also, UIKit methods should only be called on the main thread.  Exceptions and signals are usually trapped on a thread that is not the main thread.  And the main thread usually gets evicted once something catastrophic happens to the App.

CrashKit jumps back to the main thread after catching a crash and grabbing the stack frame.  It then pumps the main run loop until an email message can be sent or a HTTP method can be completed.

- (void)pumpRunLoop
{
self.finishPump = NO;
CFRunLoopRef runLoop = CFRunLoopGetCurrent();
CFArrayRef runLoopModesRef = CFRunLoopCopyAllModes(runLoop);
NSArray * runLoopModes = (NSArray*)runLoopModesRef;
while (self.finishPump == NO)
{
for (NSString *mode in runLoopModes)
{
CFStringRef modeRef = (CFStringRef)mode;
CFRunLoopRunInMode(modeRef, 1.0f/120.0f, false);  // Pump the loop at 120 FPS
}
}
CFRelease(runLoopModesRef);
}

LLVM and LLDB

LLVM and LLDB are the future.  I’ve only tested CrashKit with LLVM.  There are some LLDB features I would like to add in the future.  CrashKit probably works with GCC but I haven’t really tested it.

GitHub

The best way to download CrashKit is to check out the GitHub page.  Go put a fork in it.  Crash reporting is hard so patches welcome.

Designing a Better iPhone Sign Up Screen

I install and try a lot of iPhone Apps.  That means I have to Sign In or create a new account for a new service quite often.  I create a unique password for each web service for extra security.

I’ve also implemented Sign Up screens many times.  Here are a few things to considering when designing an iPhone Sign Up screen.

The Best Sign Up is no Sign Up

Does your services really need a Sign Up screen?  A perfectly reasonable strategy is to identify a user by the device identifier and then allow the user to create a full account later.  Two examples are Instapaper and Posterous.

[UIDevice currentDevice].uniqueIdentifier

Both Instapaper and Posterous use your email address on the web to automatically create an account.  On the iPhone, Instapaper uses the device identifier.

Sign In and Sign Up

Leah Culver has a great post on why Sign In and Sign Up should be the same.  Typing on the iPhone and managing passwords is more difficult than on a desktop machine.  It is important to minimize the amount of user error by design.

How the UI flow will be designed has be specific to how your service works.  One way to do this one screen is to use a Segmented Control and toggle between a Sign In and Sign Up state.

Embed a Table View

The best way to create a form in an iPhone App is to use a Table View.  Here is a screenshot of the Skype iPhone App.  It uses a table view to display the Skype Name and Password fields.

Screenshot of Skype Sign In screen

Skype Sign In

The key insight to the design of this page is that a table view does not have to take up the entire view.  This is how you can setup your view controller to handle this:

@interface SignupViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
IBOutlet UITableView *tableView;
}

Instead of inheriting your view controller from UITableViewController, inherit from a regular UIViewController and then implement the UITableViewDelegate and UITableViewDataSource protocols.

Embed a Text Field into a Table Cell

The next task is to embed a text field into a table view cell.  Most designs embed a descriptive label and a text field.  This is not required.  A text field has both a text and placeholder property.  The placeholder property can be used to describe the field.  This is especially important for the password field.  I tend to use very long passwords that tend to trail off the edge of a text field.

Skype Password field

Password trailing off in Skype text edit field

Source Code

This article isn’t very useful without real code that implements this functionality.  I’ve uploaded code for a TextEditCell and SignupViewController at GitHub.

DemoCamp Vancouver 11

I am helping host the next DemoCamp Vancouver. DemoCamp is an opportunity for designers, developers, and marketers to get together and show off the projects that they have been working on. It is an unconference style event that allows people to gather and meet in an informal manner.

DemoCamp Vancouver 11
Thursday, July 22nd 2010
5:30 PM
Ceili's Irish Pub & Restaurant
670 Smithe Street
Vancouver, BC

You should register on the EventBrite page.

This is a great opportunity to meet other people in the technology industry in Vancouver. What are the benefits for presenting?

PR

This is a great place to build some buzz around your project. TechVibes and a number of bloggers are always hanging out looking for new, interesting stories to write.

Cofounders

Mingle with likeminded entrepreneurs. Maybe you are a technical person that is looking for the business person to help you build the demo into a business. Maybe you are a business person and your demo is held together with duct tape and chicken wire and your looking for that technical person to take the idea to the next level.

Friendly First Contact

Find that group of friendly first contacts to test out your demo. Good BETA testers are hard to find. This is a great event to find those people that will try your service.

The hashtag on Twitter for the event is #DCV11.

Could Ruby be Apple’s language and API Future?

There has been a shift in development landscape over at Apple. John Siracusa of Ars Technica recently published an article about Apple’s language and API future. I believe Apple is preparing to transition to Ruby as their next default language.

Today

Today, the Apple development stack sits on top of the GCC compiler. GCC compiles Objective-C, C++, and C code down into native machine code for devices that run Mac OS X and iOS. Core Foundation is a set of C libraries that provide low level operating system services and fundamental data types. On the Macintosh, Cocoa is the set of frameworks that sit on top of Core Foundation. Cocoa Touch is the set of frameworks that sits on top of Core Foundation on iOS devices.

Generally, developers build applications using the XCode IDE. XCode is the GUI layer that drives the compiler, debugger, and build system.

LLVM & LLDB

XCode also ships with LLVM. LLVM is an open source compiler infrastructure that is meant to eventually replace the GCC tool chain.

LLVM allows the system to compile and optimize code at compile-time, link-time, and run-time. The compilers from Microsoft have been able to do link-time code generation for a number of years now. This allows the system an extra phase in which it can both optimize code and provide other types of diagnostics.

The LLVM project originally started at the University of Illinois. Apple has a team of developers that work on the project full time.

XCode currently ships with GDB as the debugger. The LLDB project was recently announced with the goal to replace GDB as the debugger that sits on top of LLVM. Currently, Mac OS X is the only supported platform. Browsing the list of committers shows email addressees from Apple. The project also has a very Apple-esque description:

The goal of LLDB is to provide an amazing debugging experience that “just works”.

Complete transition to the LLVM/LLDB stack will finally put Apple on par with the .NET stack that Microsoft ships. This stack contains a language agnostic runtime with multiple code optimization points that runs native code.

The Dalvik virtual machine that ships with Android interprets byte code. A byte code interpreter has a few advantages over a stack that runs native code. Performance is not one of those advantages.

MacRuby & Rubinius

Where does Ruby fit into all of this? Both MacRuby and Rubinius use the LLVM compiler infrastructure to compile Ruby into native code. The MacRuby project is driven by Apple and it sits on top o Core Foundation and uses the Objective-C runtime to execute.

Apple has implemented Blocks and Grand Central Dispatch in their latest release of the Objective-C runtime. They are available on iPhone as of the iOS 4.0 update. This is one of the features that the runtime would be required to implement to support Ruby blocks and lambda functions. Objective-C is a dynamic language as is Ruby, however this was one of the missing features between the two languages.

The Transition

A number of features still need to be implemented for a full transition to the Ruby language. However, all of the fundamental building block for this transition are there.

A hat tip goes out to Boris Mann. We had a great jam session early last week that led to a lot of clarification of my thoughts.

Farmville is the future. Farmville is filler.

Farmville is the future.

Okay, Farmville is not the future. Farmville is filler. But entertainment that is mobile, social, augmented and can be consumed on the user’s schedule is the future.

Most people just can’t justify sitting for X number of hours on their couch to play a game. The game has to fit the user and not the other way around. It has to be there when the user has a few minutes in line at a coffee shop and it has to be there when the user has an hour on a rainy Sunday afternoon.

Games like Final Fantasy are the past. There is way too much content to consume, even for a bored 12 year old, in an 80 hour game. 60 hours of Final Fantasy games are filler anyway.

Farmville is filler in 3 minute increments. Final Fantasy is filler in 30 minute increments.

Right now 3 minute increments are winning. But, eventually filler is going to lose because we live in a world where good content PageRanks its way to the top.

DemoCamp Vancouver 10: Geo Edition

I will be speaking at the next DemoCamp Vancouver in March.  DemoCamp is usually an event where speakers show off a product that they have been working on.  I have been consulting with a few companies over the last year or so about how to integrate Geo Location and Location Based Services into their existing applications and services.  Boris Mann from over at Bootup asked me to do a talk and I just couldn’t refuse.

The last time I spoke at a DemoCamp was about 2 years ago.  I was just getting out of the video game industry and had started working on iPhone Development.  Here are 2 slides from that talk:

I proposed that the magic of the iPhone was going to be the shift towards digital distribution.  The video game industry was (and still largley is) beholden to WalMart and BestBuy.  Everyone is trying to copy the iTunes distribution model these days.  In early 2008, 6 months before the iTunes App Store launched, it wasn’t actually clear if this new distribution model would actually be successful.

Hopefully, I can point out something as insightful this time around, too.

But really, you shouldn’t come to hear me speak.  You should come to hear Matt Galligan.  He will be flying up from Boulder, Colorado to talk about SimpleGeo.  SimpleGeo is building infrastructure for the next generation of location based applications.  It looks like they are up to some very cool stuff.

For my part, I will try not to duplicate what others have said elsewhere.  I am always all about the dollar.  So, I will talk about how to build a viable business in the space.  It’s early in the game, so we will look at revenue models that seem to be working today.  I’ll also point out gaps in the Geo technology stacks.  These gaps are opportunities for companies to build out good products.

Signup and More Information:

DemoCamp Vancouver 10: Geo Edition

When: Thursday March 4th, 2010

Where: Ceili’s Irish Pub. 670 Smithe Street. Vancouver, BC.

Vancouver 2010 Olympics

Vancouverites suck. There. I said it. If we are not busy complaining about the Olympics we are busy complaining about the rain. If we are not busy complaining about the rain, we are busy complaining about the Canucks.

We are our own worst enemies.

The only thing we are good at is being hospitable. In our home, we should treat guests like family.

In my home or in my city I will treat guests like family.

PERIOD.

I am ashamed of Vancouverites that don’t go out of their way to help guests in our city.

It is OUR city. We either make it BETTER or we make it worse.

The Olympics are our stage. We can be a bunch of dickheads and treat our guests with disrespect.

Or we can rise to the occasion and treat every single person that we meet with honour, respect, and kindness.

Being angry and disrespectful and dishonourable does not prove anything worthwhile. It proves we are angry, disrespectful, and dishonourable.

Be BETTER. Be way BETTER. Be magnitudes BETTER.

Measuring Obsession: How I lost 37 Lbs

The following is a list, in no particular order, of those activities that most commonly elicit Resistance:
3) Any diet or health regimen.
5) Any activity whose aim is tighter abdominals.
– Steven Pressfield. The War of Art.

Losing weight is easy.

Do 40 minutes of anaerobic activity like lifting weights three times each week.  Do 20 minutes of aerobic activity three times each week. Have egg whites and oatmeal for breakfast, tuna salad for lunch, and a chicken breast with rice for dinner.

3 hours of effort a week for a few weeks and you will have achieved your goal.

Simple, right?

Physiology versus Psychology

- If you correct your mind, the rest of your life will fall into place.
Lao Tzu

I’ve been thinking a lot about problem solving lately and the effect our own brain has on that activity.  I am a technical person.  I tend to break down all challenges into engineering problems and start applying the scientific method.

Losing weight should be easy.  Expend more energy than you consume and you will have achieved your goal.  It is that simple from a physiological perspective.

It’s much more complex from a psychological perspective.  There are a lot of moving parts that you have to manage to achieve your goals.  The brain deals with many concerns over the course of a day.  We use words like focus, motivation, tenacity, determination, and persistence to describe all of this management.  I like to use another word:

obsession |əbˈse sh ən|
noun
• an idea or thought that continually preoccupies or intrudes on a person’s mind : he was in the grip of an obsession he was powerless to resist.

Generally, the term obsession has a negative connotation.  The usual implication is that you don’t have control over your thoughts.

The plan is to tweak our brain just like we would tweak our diet or workout plan.

Before & After Pictures

I will spare you the shirtless pictures.  The first picture is my big, fat head from December 2008.  I peaked at about 197lbs.  The second picture is this morning.  I’m hovering at about 160lbs now.

Before

Before

After

After

Measure

I have one cup of coffee exactly at 6AM and another one at 3PM.  These are the perfect times for me to drink coffee and the perfect amount.  I know this because I kept a spreadsheet with every coffee I drank for 3 months.

I then correlated it with my timesheets in Harvest.  I track all of my billable and non-billable hours.  I started by tracking just working hours.  It has now expanded into tracking almost every activity.

I also did this with the amount of water I drink and how much I sleep.

You can automate a lot of this tracking.  I use an App on the iPhone called LoseIt to track every calorie I eat.  There is now also a companion website.

I also use Track Your Happiness.  This service sends me an SMS three times a day.  A follow a link on my phone and fill out a survey.  I get a set pretty graphs at the end of the month that correlate how happy I am with what activities I was doing at the time.

Automate

The easiest way to make sure your brain doesn’t get in the way is to not think at all.

The spreadsheet with with your budget probably has a macro that automatically adds up your expenses for the month.  You probably have an email filter setup for that friend that happens to send three emails a day with the subject: “FUNNIEST JOKE IN THE WORLD. LOL”

The same principle applies to your brain.  Do the thinking once, up front and then don’t allow yourself to stray the next time.  If you’ve been to my apartment, you’ve probably seen all of the checklists that I have taped up everywhere.  I scribble on all the windows with dry erase markers.

These are the exact 6 things that I do in the morning.  Every morning.

Checklist

Checklist

The Future

You probably are not as obsessive as I am.  So, how does this help you?  Well, it probably won’t.

You can start by measuring calorie intake and your happiness.  LoseIt and TrackYourHappines only take a few minutes each day if you carry around an iPhone.

However, the future is little devices that help you automatically measure all of this data.  You may have used a pedometer like the Nike+ system to count the number of steps that you take in a day.  The Fitbit, WakeMate, and Zeo are devices that measure how many calories you expend and how much you sleep amongst other things.

The onus is on you to realize that you are trying to exercise your brain and not just your body.

Conclusion

I did some ridiculous things to drop 37lbs.  I did hot yoga for 90 minutes a day for 30 days straight.  I did two a day workoutf for a month.  I wear 4 layers of clothing when I’m on the elliptical.

But really, that stuff doesn’t matter as much as keeping your head in the game.

Vancouver iPhone Forum: Touch Interface Design

The CBC, BCIT, and New Media BC will be hosting the Vancouver iPhone Forum next Tuesday.

Vancouver iPhone Forum

November 24, 2009. 8:00 AM

BCIT Downtown Campus

2nd Floor, 555 Seymour Street

Vancouver, BC

I will be presenting, along with Kevin Kimmett, a session on Touch Interface Design.  Kevin is fantastic designer that works at the CBC.  He has lead the design efforts at the CBC on their iPhone Apps.  He has designed the Hockey Night In Canada App, the CBC Radio App, as well as well as their mobile websites.

Kevin will focus on how the tools and techniques that a designer can employ to create great mobile experiences for touch devices.

I will be focusing on the technical aspects of interface design.  I will go over the mechanics of using the Interface Builder tool.  I will cover Apple’s Human Interface Guidelines.  I will also cover how technical programmers can collaborate effectively with designers.

You can follow the conversation on Twitter.  The hashtag for the event will be #vaniphone.

In App Purchases and Mobile Services

Yesterday, Apple announced that they would allow In App Purchases for free applications in the iTunes App Store.  Previously, In App Purchases were only available in paid applications.

Software As A Service

This will allow developers to shift away from the Software As A Product model to the Software As A Service model.  We have seen this shift on the Internet over the last decade with the rise of Web services.

Microsoft Office is a product but Google Docs is a service.  iWork is a product but iWork.com is a service.  iPhoto is a product but Flickr.com  and MobileMe is a service.

Going forward, we will see mobile applications integrate much more tightly with web and location services.

Freemium / Free-To-Play

Freemium is a business model that we have seen in the web services world.  Flickr is free for the most part.  A Flickr Pro account is $25/year and buys unlimited storage and analytics.

We will start seeing this model in the mobile application business.

This model is called Free To Play in the video game business.  Zynga allows you to play games like FarmVille for free.  However, you can purchase in-game currency such as coins and experience points.

Subscription

The big rumour is that Apple will release a tablet that will compete with the Amazon Kindle.  In App Purchases will allow magazines and newspapers to charge a subscription for content.  It makes sense that Apple would want to unify the way e-commerce works across all platforms and devices.