HTML5 Boilerplate Build Script: no manifest.appcache generated!

The HTML5 Boilerplate build script can auto generate your manifest.appcache file but it doesn’t out of the box.

Slightly hidden away in the docs:

To enable the appcache, just uncomment the file.manifest line in the project.properties file. It’ll create a manifest.appcache file and wire it all up.

You’ll find the project.properties file in build/project.

Now just do ant build and your HTML5 manifest file will be created and automatically referenced in your HTML file.

Xcode 4.2 Doesn’t Show Exception Stack Trace in Console

When using Xcode 4.2 for iOS development there’s an annoying bug where any exceptions crash to the main.m file instead of highlighting the line. Luckily you can set a custom breakpoint to restore the old and correct behaviour:

  1. Open the Breakpoint navigator (CMD + 6)
  2. Click the + button in the bottom left
  3. Select Add Exception Breakpoint 
  4. Click Done

Xcode 4.2 Window

Voila!

Status Barred: iOS Screenshot Status Bar Remover App

So many iOS apps developers forget to remove the screenshots from their apps on the App Store; often revealing the horrendous times the screenshots were taken and detracting from the actual app.

iTunes Connect recommends the removal of the status bar, and Status Barred removes the status bar perfectly regardless of the screenshot being retina, iPhone, iPad, landscape or portrait. For $0.99 it saves a bunch of time whenever submitting or updating an app.

Available on the Mac App Store

iOS: Show Users the Reason You Require Their Location

Update: iOS 6 deprecated the purpose property and it now has to be set in your Info.plist with the key NSLocationUsageDescription which is displayed in Xcode as Privacy – Location Usage Description. If you’re still supporting iOS 5 and earlier make sure you include both.

A great, but underused location feature on iOS is the purpose property of the CLLocationManager.

So many apps ask for your location – give your users confidence in sharing their location by telling them why you need it!

Example:

locationManager.purpose = @"We'll only use your location to show you local events nearby.";

You need to do this before you start the location monitoring, so:

CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.purpose = @"We'll only use your location to show you local events nearby.";
locationManager.delegate = self;
[locationManager startUpdatingLocation];

Your users will now get a pleasant reason when you request their permission:
iOS iPhone Screen Location Prompt

I’ve no idea why this is so rarely used, it’s been available since iOS 3.2.

Tip from the Apple docs:

You must set the value of this property prior to starting any location services. Because the string is ultimately displayed to the user, you should always load it from a localized strings file.

Using Boolean Values with TouchJSON

When creating an NSDictionary to serialize as JSON with TouchJSON you can’t set a BOOL value in the dictionary because it requires an object.

Use an NSNumber, which will be converted to true or false by the TouchJSON library.

Eg:

NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
[dictionary setObject:[NSNumber numberWithBool:YES forKey:@"shouldBeOn"];
[dictionary setObject:[NSNumber numberWithBool:NO forKey:@"shouldBeOff"];
NSError *error = NULL;
NSData *jsonData = [[CJSONSerializer serializer] serializeObject:dictionary error:&error];

Produces:

{
    "shouldBeOn": true,
    "shouldBeOff": false
}