Ghostboard pixel

Simulator vs Real Device

Simulator vs Real Device

At development time you can test your application both on the simulator and a real device. But what is the better approach?

Hint: This post has been updated to Swift 3, Xcode 8 and iOS 10

The Simulator

Out of the box Xcode provides you a lot of simulators (both iPhones and iPads), but you can also install further simulators (Preferences… -> Downloads).

The simulator has some advantages:

  • The deployment to the simulator is faster than to a real device. So you can save some time by using the simulator.
  • In most cases you don’t have all possible devices in terms of screen resolutions and iOS versions. In the simulator these is just one mouse click away.
  • It is easier to access the app folder because it is right on your Mac. Unfortunately this folder is not easy to find, but you can use a little trick to find the path very quickly. Just insert the following lines into the applicationDidFinishLaunchingWithOptions method of you app delegate. The path will then be printed to console after the app has launched:
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
            
         if let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
              print(url.path)
         }
            
         return true
    }

Real Device

Although you can do a lot with the simulator, there is no way to build an application without testing it on a real device. These are the advantages:

  • The real device is much more accurate than the simulator. There are situations where the simulator behaves differently than the real device.
  • All hardware functions like the camera and bluetooth are available.
  • You can carry the device around and you can test the app in the real world, for example in the train with a bad network.
  • If your app has some memory problems, you will see it much better on the real device. It could happen that you don’t see any signs of a memory problem in your simulator, but on your phone the app will crash right after the launch.
  • The performance of your app can only be tested on a real device, because your Mac is much faster.

Which One To Use?

The simple answer is: Use what is the best for your task. For example, if you want to debug a sqlite database inside of your application’s folder, you should use the simulator because you have easy access to it. On the other hand, if you want to test the performance of a game you should definitely use a real device.

[thrive_text_block color=”blue” headline=”Conclusion”]Both the simulator and the real device are very useful in certain situations. Try to finde the right mixture.[/thrive_text_block]

References

Image: @ rangizzz / shutterstock.com