Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use the iOS Simulator to simulate an out of disk space condition?

Tags:

What is a practical way to test an "out of disk space" condition using the iOS Simulator?

like image 596
WalterF Avatar asked Sep 19 '14 10:09

WalterF


People also ask

How do you simulate Location on iPhone 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.

Does iOS simulator simulate performance?

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.

How do you simulate an iOS device on a Mac?

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.


1 Answers

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 
like image 124
supik Avatar answered Sep 21 '22 05:09

supik