From 68fa3b3a46880e84611079ba4ab9ab936bc43714 Mon Sep 17 00:00:00 2001 From: Nathaniel Gray Date: Thu, 1 May 2014 14:30:12 -0700 Subject: [PATCH] Create a few initial subdirectories in the installed dir to mimic a standard install We've seen a crash when you install an app through Sim Deploy that didn't happen in a standard Xcode build because the tmp subdirectory didn't exist in the Sim Deploy version. Granted, it's bad form to make assumptions about directories existing, but it seems like the best thing to do is try to make a SD install as close to an Xcode install as possible. --- SimDeploy/SMSimulatorModel.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/SimDeploy/SMSimulatorModel.m b/SimDeploy/SMSimulatorModel.m index 0d4b643..8cbf0d3 100644 --- a/SimDeploy/SMSimulatorModel.m +++ b/SimDeploy/SMSimulatorModel.m @@ -199,6 +199,15 @@ - (void)installApplication:(SMAppModel *)app upgradeIfPossible:(BOOL)shouldUpgra error = nil; } + // Create some initial subdirectories to mimic Xcode's setup + for (NSString *subdir in @[@"tmp", @"Documents", @"Library/Caches"]) { + NSString *tmpPath = [destinationGUIDPath stringByAppendingPathComponent:subdir]; + if (NO == [fm createDirectoryAtPath:tmpPath withIntermediateDirectories:YES attributes:nil error:&error]) { + NSLog(@"Error creating directory %@: %@", tmpPath, error); + error = nil; + } + } + // Invalidate old application list self.userApplications = nil;