Developing iPhone Applications: Don’t Trust the Simulator
August 27th, 2009 Jeff Stonebrook, Consultant (email the author)
For many Java/C# developers, developing for a mobile device is a new experience. Of course - we have the fringe Windows Mobile and J2ME developers, but the vast majority have used Java/C# for web and application development only. In order to develop for a mobile device, you need to be able to run the software on the device, but is this the lone choice? Apple and the XCode development environment provide the iPhone Simulator, an application to run and debug iPhone software without using an actual device. While this is a fantastic productivity enhancement (reduces the time necessary to deploy the code to the device), you need to be careful with this ability.
Gotcha #1: Performance
When working with simulators, you must pay special attention to the performance of the application. The performance of the simulator on your iMac or MacBook will outshine the iPhone or iPod touch physical hardware tremendously. You have a lot more memory and MIPS on those computers than you do on the handhelds. It is crucial to get your application on a device as soon as you can in your development process to start looking for performance bottlenecks and sluggishness. And when analyzing and figuring out performance issues on your device and/or simulator – instruments are your friend…but we will leave that for another post.
Gotcha #2: Memory behavior
When dealing with Objective C code, it is a virtual certainty that you will encounter memory issues. Either you will have improper memory release issues, where you attempt to access memory that has already been released or you will have issues where you are retaining too much memory, resulting in low memory situations. The simulator simply does not mimic the behavior of the devices in these situations perfectly. The simulator seems to be much more tolerant of accessing released memory than the device. This inconsistency of how memory issues reveal themselves in running the application on the simulator or the device is just a little disheartening. You need to run your application on the device as early as possible, and take it through various scenarios/tests to reveal memory issues as soon as you can. It is much better and easier to tackle memory issues early on and throughout the project than waiting till the end and just tackling the whole list of issues.
Gotcha #3: Limited Features
The simulator is great at doing touches and pinches and even shakes now in iPhone SDK 3.0. However, you can’t do location services, you can’t do magnetometer services, you can’t do accelerometer services and you can’t do mapping services. While there are plenty of applications out there that would not need to use any of these, most of those applications would be rather dull. The iPhone/iPod touch devices are full featured devices that not figuring out unique ways to leverage these capabilities would be a shame. Therefore, most developers and product managers would tend to invent features that will use these capabilities of the devices. Now – this poses a testing problem. You simply can’t test these features on the simulator to any extent and must test with the physical device from the very beginning.
Summary
Don’t get me wrong – I am not here to bash the simulator. The simulator is a fantastic tool that greatly improves development efficiency. However, you simply just can’t rely on the simulator to give you a perfect application for your mobile devices. The main lessons learned that we wish to impart on the reader is get a device, test with the device, from very early on and throughout the project. You will be very happy that you did and you will develop a higher quality application if you do. And isn’t that what we are all after?
Entry Filed under: Agile and Development






7 Comments Add your own
1. Dave | August 27th, 2009 at 10:49 am
Great series. Keep it up
I’d love to hear some of the real-life stories about your development experience on the iPhone. Especially situations where you expected one behavior but actually experienced another. Also, I’m curious about how your world-view has changed as a result of moving from Java to Obj-C.
2. Jeff | August 28th, 2009 at 12:45 pm
Dave,
That’s exactly what we are going to try to bring to this blog series. Just a set of situations that we ran into and how we learned / got around the issues. I think you will be seeing a whole Objective C for the Java programmer series coming in the near future as well. If you have any specific questions or comments, just write them down here and we will be sure to address them.
Take care
Jeff
3. iPhone Application Development | August 29th, 2009 at 1:46 am
Thanks for sharing those special attentions while using simulator .
4. Luca Bernardi | August 30th, 2009 at 3:46 am
During an ITT, one of the first things we are told is “do not trust the simulator, the final tests are always made on the device.”
To overcome some limitations of simulator you can consider using iSimulate
5. Luca Bernardi | August 30th, 2009 at 3:48 am
Upsss…maybe ITT doens’t mean much, iPhone Tech Talk.
6. john | August 30th, 2009 at 8:45 am
And you forget things like having a headphone socket stuck in your hand when your app does not flip for example.
7. neha mishra | December 10th, 2010 at 12:14 am
Hi ,
I am getting the same problem. I am creating a music app in which there is a play all button on which all the songs play one after another it works fine on simulator but when i deployed it on device the app crashes after playing the first song.
So is this some memory related issue???
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed