What is a practical way to test an "out of disk space" condition using the iOS Simulator?
How to simulate location in Simulator. To simulate location on a Simulator, select Features menu > Location, then you will see a list of location and movement options you can simulate.
The simulator does a really lousy job of indicating app performance. In fact it doesn't try. For most things the simulator is much, much faster than an iOS device. It runs your code on an x86 processor, which is much faster than the ARM and has many times more memory.
Simulating Different iOS DevicesOpen the iOS simulator, if it's not already open. From the Hardware menu, select Device, and then select the type of device you want to simulate. The simulator window will change to match the dimensions of the device you selected.
Create a small disk image:
hdiutil create -size 2m -fs HFS+ /tmp/2meg.dmg
Mount it to the relevant directory in your simulator app, e.g.:
hdiutil attach /tmp/2meg.dmg -mountpoint /Users/.../Library/Developer/CoreSimulator/Devices/.../data/Applications/.../Library/Caches
Run app and perform your tests. This can also be done while the app is running. In this case you probably don't want to mount it as Caches
or Documents
directory directly because this would hide current files in those folders. Mount to a sub-directory instead. If this is not easily possible without changing paths in your app, mount the image somewhere else and copy data over before mounting it on top of the nonempty directory.
To unmount:
hdiutil detach /Users/.../Library/Developer/CoreSimulator/Devi...
However, please note that the detach operation fails if the mount point is moved. This happens all the time because Apple renames simulator directories on iOS 8 every time an app is run. In this case use the mount
command to find the device you have mounted, e.g. /dev/disk3s1 /Users/.../Library/...
, then unmount the disk image using the device name instead of the mount point:
hdiutil detach disk3s1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With