Matt
Matt

Reputation: 910

How do I speed up app launch in iPhone Simulator?

The problem is that my app saves hundreds of megabytes into the users document directory on their iPhone. During testing, the iPhone simulator takes a long time to launch the app on each build as it is copying all of this data to a new documents directory each time I rebuild. Is there any solution to this that will just leave the directory in the same place each time or speed up launch in some way? For example, the director with HEX values change each rebuild/relaunch on the iPhone Simulator and it can be quite time consuming:

./Library/Application Support/iPhone Simulator/User/Applications/B32A0BA1-5843-4FDE-B5FB-4E40460BD8CC/Documents/

Thanks,

Matt

Upvotes: 2

Views: 4532

Answers (4)

soelu
soelu

Reputation: 574

Just leave the Simulator open after the first run. Just stop the program in XCode without closing the Simulator. So in the next test-launch it only has to load the app without loading the simulator again.

It really sped up thing for me.

Upvotes: 2

Matt Gallagher
Matt Gallagher

Reputation: 14968

The simulator (unlike the device itself) doesn't have to keep to the sandboxed locations.

So when saving files from the simulator, you could try:

#if TARGET_IPHONE_SIMULATOR

// save your files to a fixed location on your hard-disk
// (like /Users/yourusername/MyIPhoneAppDebugStorage)

#else

// Save files normally
// (to [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
//     NSUserDomainMask, YES) objectAtIndex:0])

#endif

That way, your large files are always at a fixed place on your harddisk when running from the simulator.

Upvotes: 11

PyjamaSam
PyjamaSam

Reputation: 10425

XCode doesn't make a new directory each time you build and run, it just renames the old one.

I have data that I store in the documents directory and its there every launch unless I explicitly delete it before running my app.

I'd be curious as to where the time is taken when launching the simulator. Can you debug through the app? (is it your code thats taking the time?)

chris.

Upvotes: 0

Mark Bessey
Mark Bessey

Reputation: 19782

To shorten your build time, the easiest thing is probably to create a new XCode target that includes a reasonable subset of the data. Assuming that these data files are "Resource" files in the XCode project, you can duplicate your app target, rename it "app lite" or some-such , then edit the "Copy Resources" build phase to not include all of the files (or a single smaller file, or whatever).

Upvotes: 0

Related Questions