在模拟器上“构建并运行”大约需要 30 秒
在设备上“构建并运行”大约需要 5 分钟。
我 99% 确定原因是我有很多图像(~4000 ~80mb)。
构建本身阶段大约需要 2 秒,因此问题在于安装。
有人有任何加快速度的技巧吗?图像不需要改变,那么是否可以告诉xcode不要每次都复制图像?还是有其他因素会减慢速度?
谢谢
最佳答案
我的解决方案是在我的 Mac 上设置一个 zip 文件,然后让 iPhone 应用程序检测资源是否已下载,如果没有,则从 Mac 中获取它们并解压缩。然后应用程序很精简,可以下载它需要的内容。这仅用于调试目的,最后,您希望安装所有 Assets ,因此人们在安装后不必下载。相关代码看起来像这样(没有错误检查,您可能需要调整路径)。我一直在使用优秀的ASIHTTP library ,以及 ZIPArchive项目。您需要更改下载 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]; }
关于iphone - xcode 在模拟器和设备上安装速度很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3084557/