Joris Kluivers

I like to build software.

Code Snippets in Xcode4

Xcode4 introduces user customizable code snippets as a prominent feature in the editor.

How to add a new snippet:

  1. Select the text you wish to create a snippet for

  2. Drag the code to the snippet library

  3. Introduce variables using <# Title #> markup

  4. Save.

From now on I’ll post useful snippets I’m using on this weblog: follow the tag snippet for updates.

Amazon Appstore Dev Blog and Twitter Account

As of two weeks ago the Amazon Appstore Developer Portal is open for developers to submit their Android apps.

Today Amazon launched a developer blog with answers to common questions and best practices related to the Appstore. Developers should also follow @amznappstoredev to be kept up to date via twitter.

The Amazon Appstore is an alternative to the official Google Market and will enforce stricter rules in an effort to offer a better selection of apps. Pricing will be determined by the developer, but Amazon is free to offer the app for a discount price for example. Amazon already employs sophisticated algorithms in their stores to offer recommendations which could easily applied to the Appstore. It will be interesting to see how the Amazon Appstore will compare to the Google Market and if it will offer a significant advantage to developers.

Speed-up Eclipse on OS X

While developing for Android on OS X you might notice (read: get really annoyed with) how slow Eclipse is.

Switching tabs took over 10 seconds for example. Luckily I’m not the only one with this problem: turns out that the default settings for Helios and Galileo are not optimal on the latest versions of OS X.

To quote a solution by Yasin Bahtiyar:

If you experience such a behavior you should modify -Dosgi.requiredJavaVersion parameter in eclipse.ini and change the value to 1.6 as a workaround. And then it will run perfectly smooth.

I prefer to increase the memory settings also. Here is related part of my eclipse.ini file:

<code>-Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=512m
-Xms128m
-Xmx1024m</code>

The eclipse wiki explains where to find the eclipse.ini file on OS X.

Hardboiled Web Design by Andy Clarke

This is a guest post by Jeffry van der Goot (@jvdgoot). While the book is not specifically targeting mobile,  the techniques are equally applicable in recent modern mobile browsers.

Hardboiled Web Design book Cover

Hardboiled Webdesign by Andrew Clarke is part manifesto and part cookbook. In the first part of the book Clarke describes his design philosophy. Instead of designing websites so that they look identically, to the pixel, in every browser, you take a top-down approach. Make use of the most bleeding edge features in modern browsers and give less modern browsers what they can handle.

The remaining 3/4ths of the book contains practical examples of HTML5 and CSS3 techniques you can use to enhance your website. Clarke not only shows you how to use cool fancy tricks, but also shows you real life examples and explains how they improve the experience for the user.

Hardboiled Webdesign not only lays out a design philosophy I totally agree with (and wish would spread rapidly) but is a tremendously useful reference book for HTML5 and CSS3 features. If you’re building webapplications in the 21st century, this should be on your (virtual) bookshelf.

Multi-line UITableViewCell

On multiple occasions I needed to display multi-line text in a UITableViewCell. For example to display an address I would prefer to use a single cell with multiple lines of text, like the Contacts app does.

Previously I would always create custom UITableViewCell subclasses. Thankfully Ahmed Abdelkader found out how to configure a default cell to display multi-line text without any subclassing.

To create a cell similar to the one in the Contacts app:

1
2
3
4
5
6
7
8
9
10
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2
     reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"work';
cell.detailTextLabel.text = @"Kosterijland 42\n3981 AJ Bunnink\nNetherlands";
cell.detailTextLabel.numberOfLines = 3;
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;

Make sure the table view also knows about the correct height.

1
2
3
4
5
6
- (CGFloat) tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (/* my address row */) {
        return  (44.0 + (numberOfLines - 1) * 19.0);
    }
    return 44.0;
}

The formula 44.0 + (numberOfLines - 1) * 19.0 is derived from measurements on cells with different number of lines in the Contacts application.

(via)

LLVM 1.5 and SDK 4.1

After upgrading Xcode to SDK 4.1 (the latest official release at that time) all my projects compiled with LLVM 1.5 failed to compile. The build logs showed a lot of weird errors in Objective-C runtime classes, not in any of my code.

Turns out the 4.1 SDK somehow breaks the __IPHONE_OS_VERSION_MIN_REQUIRED macro. There are two solutions available:

  1. Change to any compiler not using LLVM or base SDK 4.1

  2. Set the macro manually: add the following line to ‘Other C Flags’: -D__IPHONE_OS_VERSION_MIN_REQUIRED=030000. (Change 030000 to the minimum version you require)

This will ensure you’re projects will compile correctly again using the LLVM compiler using SDK 4.1

Wireless Ad-Hoc Distribution

Somewhere hidden a bit hard to find on the Apple iOS developer website this small guide on Distributing Enterprise Applications for iOS 4 Devices can be found. Amongst other things this guide explains how to install your app and provisioning profile wirelessly.

Turns out that while the guide is for Enterprise distribution, wireless distribution also works for normal ad-hoc apps. Jeffrey Sambells wrote a short article explaining the basic requirements for wireless Ad-Hoc distribution. It involves special links in html and a xml plist file describing your IPA archive. Jeffrey even created a php script to automate much of the work.

Even more simpler is the recently released app called iOS Beta Builder. After you Build & Archive (you do archive right?) simply select the generated IPA and iOS Beta Builder creates the required webpage and manifest xml. Upload to the server and your app is ready for download. No custom scripts needed.

The Hockey framework also uses wireless distribution, and wraps it to provide an automatic update functionality for iOS apps (not unlike Sparkle on the desktop). Using Hockey your ad-hoc users will be notified of new builds as soon as they are available.

Still in private beta is TestFlight. I’ve only seen a short video, but it appears to be an all integrated environment that offers wireless ad-hoc distribution with review and feedback opportunities for testers.

As frustrated as ad-hoc distribution might have been in the past, Apple is certainly improving the process. The third party tools mentioned above really make ad-hoc distribution as simple as possible.

(Like before, wireless ad-hoc distributions still require each device to be included in the provisioning profile).

App Store Promo Codes

As an iOS developer you’ve got the possibility to create promo codes using iTunes Connect. Each version of your app entitles you to 50 promotional codes which after given out to users can be used to get a free version of your app.

[caption id=”attachment_13” align=”aligncenter” width=”357” caption=”iTunes connect link to redeem codes”][/caption]

It only requires a few simple steps for a user to redeem a code:

  1. Login to iTunes

  2. Go to redeem page

  3. Copy the code from the developer website/email to iTunes

  4. Click the Redeem button

This is all fine, but there is a way as a developer to optimize this process:

An undocumented way of linking allows you to directly jump to the redeem page, with code filled in already. Use the following links on your website, in your email or in twitter posts to create the process of getting your app for free a bit simpler.

https://phobos.apple.com/WebObjects/MZFinance.woa/wa/freeProductCodeWizard?code=REPLACEWITHPROMOCODE

(via tap tap tap)

Piracy Heat Map for an Android App

[caption id=”attachment_9” align=”aligncenter” width=”440” caption=”Piracy Heatmap for Screebl Pro”][/caption]

If I’m not pirating apps, and you aren’t, and no one knows anyone who is, where is the piracy coming from?

To answer the question of who is pirating the Screebl Pro Android app, it’s developer whipped up a chart with piracy numbers per country of the world. (The number of installations compared to the number of actual sales for that country).

It turns out 67% of the total number of 8659 installations were pirated. Out of all pirated installs only 14% came from countries that don’t support the purchase of apps in the Android Market.

Top countries with the highest number of pirated installs out of the total installs for that country:

  1. Australia (92%)

  2. Italy & Spain (both 89%)

  3. France (78%)

  4. Germany & Netherlands (both 76%)

  5. Canada (74%)

(via tweakers.net)