Posts Tagged ‘iphone’

Link roundup: Dead fish in the Hudson

Lasso me some links

Lasso me some links

Link roundups are legitimate blog posts, right? It doesn’t matter because I’m going to post it anyhow.

We’ll start with programming-related topics:

Next off to the bizarre sciency stuff:

What is more off-topic than dead salmon? These links:

 

Google Wave on the iPhone

By default the Google Wave interface in Firefox on a PC has a lot of thrown at you. I was curious how the service looked on a small device, in this case, an iPhone.

First thing out the gate was not reassuring. Yes, it’s a dreaded “unsupported browser” message:


From Google Wave on the iPhone

Of course there’s no fun in stopping there, I had to go further down the rabbits hole by telling Google I wanted to proceed anyhow.


From Google Wave on the iPhone

Yup, it’s a listing of waves in a webpage clearly designed for a mobile device. In this case, a listing of waves in my inbox.

Naturally I had to take a look at how a wave is displayed.


From Google Wave on the iPhone

More screenshots can be found in my Picasa web album cleverly titled “Google Wave on the iPhone“.

Overall it is clear a lot of effort has gone into making Google Wave work and display well inside of a browser.

Performance was another issue altogether. Despite visiting Google Wave on a wifi connection, the site dragged so bad it was effective unusable. On a second visit performance was quite a bit snappier. I shutter to think about the performance if I was to use 3G or even Edge.

 

Using Xcode and Guard Malloc should be easier than this.. could not load inserted library: libgmalloc.dylib

After running into a nasty (read: can’t figure it the problem) EXC_BAD_ACCESS error I turned to guard malloc.

Enabling guard malloc in Xcode is deceptively simple: Run > Enable Guard Malloc. Done. Easy right?

It would be, and I believe it is supposed to be this simple. Of course when I run the app in debug mode through the iPhone Simulator I get a EXC_BAD_ACCESS error right off the bat. The debug console is a little more helpful here:

dyld: could not load inserted library: /usr/lib/libgmalloc.dylib

I do not find it inside /usr/lib. I do find it located in /Devloper/usr/lib as well as /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib.

I have updated to , so maybe this has something to do with it? I’m going to try the only thing I can think of and install the iPhone SDK 3.1.2 with Xcode 3.2.1.

Apparently I don’t know what I’m doing. Luckily Google is giving me comfort in knowing I’m not alone. However, it would be better if I hadn’t burned two hours so far on a EXC_BAD_ACCESS error…

Update: Upgrading to Xcode 3.2.1 does the trick. Weird.

 

Rantings and failures about unit testing iPhone apps

Apple Headquarters

I’ve been trying to write unit tests for any iPhone apps that I write. With Xcode, that’s much much easier said than done (it should not be this difficult!).

I’ve tired a couple of frameworks and tried to follow several steps found on Google. So far nothing is doing the trick.

My latest effort followed instructions for using OCUnit written by Sen:te. After following the steps outlined, I get this error when compiling and running the project:

error: Testing rig /Somepath/iPhoneSDKVersion/otest exited abnormally with code 139 (it may have crashed).

Naturally I turned to trusty Google which came up with nothing helpful.

Thinking that it was a failure to follow the directions, I downloaded the sample test application, loaded the project in Xcode, then built and ran the project. Same error.

I tweeted to Michael Galpin, a programmer at eBay, asking for any ideas on unit testing iPhone apps. Since he had just given two presentations on mobile development [1, 2] for the Silicon Valley Code Camp 09, I thought he might have some ideas.

His initial response does not give me good feelings about iPhone development:

I’ve only seen homebrewed stuff. XCode is not exactly extensible.

He did turn me to the google-toolbox-for-mac which has some promising instructions on doing iPhone unit testing.

Using Xcode feels something like this...

Using Xcode feels something like this...

What bothers me about doing iPhone development is that I am leaving all my very excellent development tools for iffy tools.

Sun wants Java on the iPhone and is willing to make it happen. Java has one hell of a community behind it and Apple could really benefit from it.

Unfortunately someone at Apple has some bad information on Java.

Perhaps Apple is just interested in keeping it’s pet language alive and kicking. After all, Apple seems to have problems with Not Invented Here.

This was not really meant to turn this into a bit of an Apple hate-fest. It’s just that the tools and community that Java has is light years ahead of what Apple is offering anyone interested in iPhone app development.

When I’m effectively boxed into Xcode to do iPhone development, that’s a problem. I would like an IDE that doesn’t seem to break at least one thing every update. Chris Hanson’s steps to setting up unit tests has required updating between various Xcode updates.

More importantly, the barrier to entry for unit testing iPhone apps is painfully high. I have almost given up and I’m already sold on the idea of unit testing. Imagine if I wasn’t already sold.

google-toolbox-for-mac is next up for me to try. Wish me luck, I’ll need it.

 

Compiling MGTwitterEngine for the iPhone using Xcode

Surprisingly there are not a lot of options for Objective-C Twitter libraries. In fact there are exactly two options: MGTwitterEngine and Canary (which is actually a “full-fledged client”). The choice looks clear, use MGTwitterEngine or deal with XML directly (yuck!).

MGTwitterEngine does not implement the entire Twitter API but it does implement the most important things like updating status, retrieving your friend’s timeline, etc. For my current uses, that’s all I need.

It took me a little bit of effort to get MGTwitterEngine compiling and running correctly:

  1. Checkout the project from subversion (svn co http://svn.cocoasourcecode.com/MGTwitterEngine-1.0.8/).
  2. Delete files that aren’t needed: .svn, AppController.h, AppController.m, English.lproj, Info.plist, main.m. Optionally delete README.txt, TODO. Leave alone Source Code License.rtf.
  3. Add the remaining sources to your project.
  4. Change USE_LIBXML to 1 (instead of 0) to use libxml for a smaller footprint.
  5. In your target, within the general tab add libxml2.dylib.
  6. In your target, within the build tab, add to “header search path”: “${SDKROOT}/usr/include/libxml2″. Make sure you’ve selected the recursive checkbox.

If you are getting an error saying “error: libxml/xmlreader.h: No such file or directory”, make sure you’ve completed the last 2 steps listed above.

A working example can be found on an early commit to my iPhone app hosted on github.

 

Swift bank code is required to receive payments from the Apple iPhone App Store sales

I tried to add my USAA bank account as my bank account to receive payments from Apple’s iPhone App Store. Unfortunately USAA does not have a swift bank code (see their FAQ on the subject).

I emailed Apple on the subject, here’s their reply:

Dear Ash,

The iTunes App Store makes Applications available for sale to customers around the world. Apple uses various global currencies to pay you, depending on the customer’s location. Apple pays via wire or electronic transfer, using a “SWIFT code” to route these payments. If a SWIFT code is not on file for you, Apple cannot pay you for purchases made by global customers.

If you do not have an account with a bank that utilizes a SWIFT code, Apple recommends you establish such an account at your earliest convenience. Large, international banks utilize SWIFT codes. Credit Unions do not have this capability.

Apple does not recommend any particular bank, and recommends you research to determine which bank will best meet your needs.

Examples of US-based banks that utilize SWIFT codes:
Bank of America
JPMorgan Chase Bank
Wachovia Bank
Wells Fargo Bank
Citibank

Examples of Canada-based banks that utilize SWIFT codes:
CIBC
RBC
TD Canada

Apple may send multiple payments each month, depending on the regions and currencies in which you had activity. Your bank will handle any currency conversions when payments are applied to your account.

For reference, the locations and currencies are listed below.
United States – USD
Canada – CAD
Europe – EUR
United Kingdom – GBP
Australia – AUD
Japan – JPY
Rest of World – USD

If you have any further questions, please don’t hesitate to contact us.

Kind regards,

Callie
iTunes Finance
 Apple Inc.

I hope Arvest has a swift code, otherwise I’ll have to open yet another bank account with yet another company.

 

iPhone App Store sales (free download) statistics, first 10 weeks

As some of you may know, I’ve got an app in the iPhone App Store called Xbox Points. It’s a free app that does one thing: convert Microsoft Points to various currencies including USD, USD, AUD, CAD, EUR, GBP, and JPY.

Last I checked, there were three or four iPhone apps that have this exact functionality. Although they look more polished, all of them charged at least $0.99. So for my competition, mine is the only one that is free. Although some of the non-free versions also convert Nintendo Points.

You can check out the full data hosted on Google Fusion Tables.

Downloads per week (excluding updates)

On average the app is downloaded 529.2 times per week or 75.6 times per day. Not bad for a simple but functional app (I actually use it on occasion).

The below graphs and charts show the total sales (excluding updates) per week. I made a mistake and the second week is missing, but I think these charts get the point across quite well anyhow.

xbox-points-sales-per-week-2

xbox-points-sales-per-week

Total sales by country

Not surprisingly the United States leads the list of downloads per country.

To make this information more digestible, I’ve excluded 28 countries with less than 5 downloads.

xbox-points-sales-per-country

Updates per week

I submitted an update (it took 3 weeks to get approved, ugh). During the week of 6/29/2009 my update was released to the App Store.

Even if Xbox Points was a paid app, updates would be free.

xbox-points-updates-per-week-2

xbox-points-updates-per-week

What the…?

Just for fun, I’d like to point of some of the WTF-worthy review comments left for my app:

Review by =^.^=donkey on July 3, 2009:

I don’t know wat to do in this app do u get free points?

Review by xxRambo15xx on July 8, 2009:

I don’t know do u buy the points at whatever price u want or u get them 4 free

Review by Caddy239 on July 20, 2009:

How do u use this app do have 2 pay 4 it or is it free idk wat 2 do with it.

Review by pimp22juice on June 29, 2009:

How does this app work and do I get fre points

Review by Dsneek on July 28, 2009:

How do you even work this????????write back

Well, that’s the internet for you…

 

First look at Apple’s App Store ratings system – Your iPhone is safe!

I somehow missed the flurry of Apple news today, so I was surprised to see the updates to iTunes Connect when I wanted to check up on the number of downloads for my first iPhone App Store application (it was approved late last night). I haven’t seen much talk on the Apple’s App Store ratings, so here’s the tiny bit of details that I’ve seen about this new feature.

Before an iPhone developer can update an existing app or upload a new app, they must select the ratings for their own applications:

appstore-content-descriptions

iPhone developers are asked to choose the content frequency (None, Infrequent/Mild, and Frequent/Intense) of various types of objectionable content.

I find it very interesting that developers are being asked to provide these details. Presumably the developers themselves would know about any Hot Coffee-eque features to their apps and fess up, right? I assume the game plan is for the employees already swamped with app approvals will be in charge of validating the accuracy of the developer’s own ratings.

App Store Ratings 4+, 9+, 12+, 17+

App Store Ratings

Apple apple appears to have their very own ratings system:

  • 4+, Applications in this category contain no objectionable material.
  • 9+, Applications in this category may contain mild or infrequent occurrences of cartoon, fantasy or realistic violence, and infrequent or mild mature, suggestive, or horror-themed content which may not be suitable for children under the age of 9.
  • 12+, Applications in this category may also contain infrequent mild language, frequent or intense cartoon, fantasy or realistic violence, and mild or infrequent mature or suggestive themes, and simulated gambling which may not be suitable for children under the age of 12.
  • 17+, Applications in this category may also contain frequent and intense offensive language, frequent and intense cartoon, fantasy or realistic violence, frequent and intense mature, horror, and suggestive themes, plus sexual content, nudity, alcohol, tobacco, and drugs which may not be suitable for children under the age of 17.

Interestingly no application will be sold on the App Store that has “Prolonged graphic or sadistic realistic violence” or “Graphic sexual content and nudity” regardless of the frequency or severity. I guess that means we won’t be seeing any porn anytime soon.

Apple also provides a chart showing the app store rating system’s equivalent to the ESRB and PEGI rating systems:

Are these are equivelent?

Are these are equivelent?

Hopefully this will eliminate the controversy surrounding the rejection of apps due to its objectionable content.

More importantly, I hope the ratings system does not delay the approval process anymore.

Enjoy the new iPhone OS 3.0 upgrade in about a week. Since I’m impatient I might finally grab the version already available to developers. If anything is hosed, I’ll be hosed in a about week anyhow.

 

Saving app data with the iPhone SDK and Cocoa is easy with NSUserDefaults

A quick look at NSUserDefaults suggests saving app data with Cocoa and the iPhone SDK is easy. I haven’t gotten much of a chance to use it so there might be some gotchas.

To store nonsensitive data using NSUserDefaults is as easy as a couple of lines of code:

[objc]
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:usernameTextField.text forKey:@"username"];
[defaults synchronize];
[/objc]

The last line is particularly important as it actually saves the data to disk.

Retrieving data is equally as easy:

[objc]
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSLog([defaults objectForKey:@"username"]);
[/objc]

NOTE: Using NSUserDefaults is a really bad idea for sensitive data like passwords. A significantly safer solution would be to use the iPhone’s keychain. Apple has an example found in GenericKeychain.

The API can be difficult to understand and cumbersome to use. Luckily, there is a solution for that from Buzz Anderson and it can be found on github.

 

How to: HTTP POST and Google’s ClientLogin using Objective-C and the iPhone SDK

PLEASE NOTE (2009-08-12): You probably do not want to use this method (though it’s great for learning). A much better solution is to use the gdata-objectivec-client. Example code on using that library can be found in one of my projects hosted on github.

I’ve been working on an iPhone app that uses one of Google’s APIs.  The following appears to work just fine in a non-jailbroke phone.

Creating the request

[objc]

NSURL *url = [NSURL URLWithString:@"https://www.google.com/accounts/ClientLogin"];

NSMutableURLRequest *loginRequest = [NSMutableURLRequest requestWithURL:url];

[loginRequest setHTTPMethod:@"POST"];</code>

//set headers

[loginRequest addValue:@"Content-Type" forHTTPHeaderField:@"application/x-www-form-urlencoded"];

[loginRequest addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];

NSString *requestBody = [[NSString alloc]

initWithFormat:@"Email=%@&amp;Passwd=%@&amp;service=finance&amp;source=%@",

username, password, [NSString stringWithFormat:@"%@%d", @"ashlux-igFinance-1.0"]];

[loginRequest setHTTPBody:[requestBody dataUsingEncoding:NSASCIIStringEncoding]];

[/objc]

This part is fairly straight-forward. The service=finance should be changed to the Google service you are using.  Also ashlux-igFinance-1.0 should be changed to the format company-appname-version.

The default timeout interval for the request connection is 60 seconds.  To change this, use setTimeoutInterval:

[objc]

[loginRequest setTimeoutInterval:30]; // set timeout for 30 seconds

[loginRequest setTimeoutInterval:90]; // set timeout for 90 seconds

[/objc]

Sending the request

To send the request, I am sending a synchronous request (which will block) to Google:

[objc]

NSHTTPURLResponse *response = NULL;

NSData *responseData = [NSURLConnection sendSynchronousRequest:loginRequest returningResponse:&amp;response error:nil];

NSString *responseDataString = [[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding];

NSLog(@"Response from Google: %@", responseDataString);

[/objc]

Objective-C does have asynchronous IO (non-blocking), but that’s for another time.  For most purposes, asynchronous is the way to go to avoid blocking the application.

Reading the response

For my purposes, I am storing the data in a struct called GoogleClientLogin to represent Google’s ClientLogin data (that’s simple enough, so I will not list it here).  For simplicity, I am not interpreting the response status beyond success (code=200) and failure (code=anything else).

[objc]

if ([response statusCode] == 200) {

NSLog(@"Login successful.");

GoogleClientLogin *aGoogleClientLogin = [GoogleClientLogin alloc];

aGoogleClientLogin.username = username;

aGoogleClientLogin.password = password;

NSString *authToken = [[responseDataString componentsSeparatedByString:@"Auth="] objectAtIndex:1];

NSLog(@"Google authToken=%@", authToken);

aGoogleClientLogin.authToken = authToken;

return [aGoogleClientLogin autorelease];

} else {

NSLog(@"Login failed.");

return nil;

}

[/objc]

That is more or less all there is to it. There is room for better error handling, but the effort would be better spent elsewhere on the applcation.

Next up, I’ve really need to figure out how to work in unit tests using Xcode.  My previous attempts at getting OCUnit working were full of fail special thanks to Apple’s out-of-date documentation.