Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does building for iOS device and simulator actually differ?

Since the iOS simulator is a simulator, why do I need to build specifically for it? Isn't the point of a simulator that it runs the real code in some sort of VM/sandbox?

So what are the actual differences in how building for device/simulator works, and how the resultant built apps differ?

like image 960
Mr. Boy Avatar asked Apr 18 '12 08:04

Mr. Boy


3 Answers

An application running natively on an iOS device is an ARM program. However, an application running in the iOS Simulator is an ordinary 32-bit (i386 architecture) Mac OS X program. In other words, the Simulator doesn’t simulate an iOS device down to the hardware level. It provides a faithful copy of the iOS environment, reimplemented to run natively on the Mac.

like image 120
Vignesh Avatar answered Oct 21 '22 05:10

Vignesh


The simulator build uses the i386 instruction set, since that is what your mac uses.

When you build for an iOS device, you are building either for the armv6 or armv7 instruction sets.

The point of the simulator is so that you can do some quick testing on your mac, without needing to use a device.

To learn more about instruction sets: http://en.wikipedia.org/wiki/Instruction_set

like image 44
Rahul Iyer Avatar answered Oct 21 '22 05:10

Rahul Iyer


The simulator and the device should run the same code just the same, nevertheless there are few issues that one should take it mind.

  1. The simulator can not run all functionality which the device can run, for example the simulator does not interact with a camera, GPS data is not present (but you can set a fixed location from the options) , and there are few other things along those lines.

  2. The simulator can be used to check your code and functionality much faster than dumping your code on the device while developing, nevertheless the simulator is using your computer's memory and CPU which means that it does not reflect the performances on a real device, speed and memory wise.

Good practice would be to test and develop mostly on the simulator, when your code and stable and working as planed - it is time to test it on the device itself for performances and other issues that are device specific.

I can elaborate more on the topic, but I this is a quick answer to your question.

like image 41
chewy Avatar answered Oct 21 '22 04:10

chewy