开发者

xcode slow to install on simulator and device

To 'build and go' on the simulator takes about 30 seconds

To 'build and go' on the device takes about 5 mins.

I am 99% sure the reason is that I have lot of images (~4000 ~80mb).

The build itself stage takes about 2 seconds, so the problem is the install.

Does anyone have any tips to speed it up? The images do not need to be changed, so is it possible to 开发者_开发技巧tell xcode not to copy the images each time? Or could something else be slowing it down?

Thanks


My solution for this was to setup a zip file on my Mac, then have the iPhone app detect if the assets were downloaded, if not, grab them from the Mac and unzip. Then the app is slim, and downloads what it needs. This is only for debugging purposes, in the end, you would like to have all the assets installed, so people don't have to download after they've installed. The relevant code looks something like this (no error checking, and you may need to adjust the paths). I've been using the excellent ASIHTTP library, and the ZIPArchive project. You'll need to change your download URL.

  BOOL isDirectory;
  BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:installDirectory  isDirectory:&isDirectory];
  NSLog ( @"Checking for file: %@", installDirectory );
  if ( !fileExists ) {
    NSString* path = [docsPath stringByAppendingString:@"foo.zip"];
    NSLog ( @"Download file!" );
      NSURL *url = [NSURL URLWithString:@"http://10.0.0.11/~blezek/foo.zip"];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDownloadDestinationPath:path];    
    [request startSynchronous];

    // Now unzip
    ZipArchive *zipper = [[[ZipArchive alloc] init] autorelease];
    [zipper UnzipOpenFile:path];
    [zipper UnzipFileTo:docsPath overWrite:NO];

    NSFileManager *fileManager = [NSFileManager defaultManager];
    [fileManager removeItemAtPath:path error:NULL];
  }


Xcode apparently supports incremental updates, which is why sometimes "build and go" doesn't do a complete app update (it's very annoying).

The easiest thing might be to "install" things into Documents or similar, which is persisted across app updates. Hopefully it moves the files instead of copying.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜