How does building for iOS device and simulator act

2019-02-13 19:56发布

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?

3条回答
何必那么认真
2楼-- · 2019-02-13 20:18

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.

查看更多
Bombasti
3楼-- · 2019-02-13 20:25

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.

查看更多
劳资没心,怎么记你
4楼-- · 2019-02-13 20:28

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

查看更多
登录 后发表回答