Index: testing/iossim/iossim.mm |
diff --git a/testing/iossim/iossim.mm b/testing/iossim/iossim.mm |
index d66296f0a3e7e4284303123a53a9a23a7ad9b13f..a746bc4c03c3043a1f76870ae2f3e4a0cf87e9cb 100644 |
--- a/testing/iossim/iossim.mm |
+++ b/testing/iossim/iossim.mm |
@@ -21,16 +21,9 @@ |
// However, there are some forward declarations required to get things to |
// compile. |
-// TODO(lliabraa): Once all builders are on Xcode 6 this ifdef can be removed |
-// (crbug.com/385030). |
-#if defined(IOSSIM_USE_XCODE_6) |
@class DVTStackBacktrace; |
#import "DVTFoundation.h" |
-#endif // IOSSIM_USE_XCODE_6 |
-// TODO(lliabraa): Once all builders are on Xcode 6 this ifdef can be removed |
-// (crbug.com/385030). |
-#if defined(IOSSIM_USE_XCODE_6) |
@protocol SimBridge; |
@class DVTSimulatorApplication; |
@class SimDeviceSet; |
@@ -39,7 +32,6 @@ |
@class SimRuntime; |
@class SimServiceConnectionManager; |
#import "CoreSimulator.h" |
-#endif // IOSSIM_USE_XCODE_6 |
@interface DVTPlatform : NSObject |
+ (BOOL)loadAllPlatformsReturningError:(id*)arg1; |
@@ -77,10 +69,6 @@ namespace { |
const char* const kUserHomeEnvVariable = "CFFIXED_USER_HOME"; |
const char* const kHomeEnvVariable = "HOME"; |
-// Device family codes for iPhone and iPad. |
-const int kIPhoneFamily = 1; |
-const int kIPadFamily = 2; |
- |
// Max number of seconds to wait for the simulator session to start. |
// This timeout must allow time to start up iOS Simulator, install the app |
// and perform any other black magic that is encoded in the |
@@ -118,7 +106,6 @@ const int kExitInvalidArguments = 2; |
const int kExitInitializationFailure = 3; |
const int kExitAppFailedToStart = 4; |
const int kExitAppCrashed = 5; |
-const int kExitUnsupportedXcodeVersion = 6; |
void LogError(NSString* format, ...) { |
va_list list; |
@@ -185,74 +172,17 @@ NSString* GetOutputFromTask(NSString* toolPath, NSArray* args) { |
encoding:NSUTF8StringEncoding] autorelease]; |
} |
-// Finds the Xcode version via xcodebuild -version. Output from xcodebuild is |
-// expected to look like: |
-// Xcode <version> |
-// Build version 5B130a |
-// where <version> is the string returned by this function (e.g. 6.0). |
-NSString* FindXcodeVersion() { |
- NSString* output = GetOutputFromTask(@"/usr/bin/xcodebuild", |
- @[ @"-version" ]); |
- // Scan past the "Xcode ", then scan the rest of the line into |version|. |
- NSScanner* scanner = [NSScanner scannerWithString:output]; |
- BOOL valid = [scanner scanString:@"Xcode " intoString:NULL]; |
- NSString* version; |
- valid = |
- [scanner scanUpToCharactersFromSet:[NSCharacterSet newlineCharacterSet] |
- intoString:&version]; |
- if (!valid) { |
- LogError(@"Unable to find Xcode version. 'xcodebuild -version' " |
- @"returned \n%@", output); |
- return nil; |
- } |
- return version; |
-} |
- |
-// Returns true if iossim is running with Xcode 6 or later installed on the |
-// host. |
-BOOL IsRunningWithXcode6OrLater() { |
- static NSString* xcodeVersion = FindXcodeVersion(); |
- if (!xcodeVersion) { |
- return false; |
- } |
- NSArray* components = [xcodeVersion componentsSeparatedByString:@"."]; |
- if ([components count] < 1) { |
- return false; |
- } |
- NSInteger majorVersion = [[components objectAtIndex:0] integerValue]; |
- return majorVersion >= 6; |
-} |
- |
// Prints supported devices and SDKs. |
void PrintSupportedDevices() { |
- if (IsRunningWithXcode6OrLater()) { |
-#if defined(IOSSIM_USE_XCODE_6) |
- printf("Supported device/SDK combinations:\n"); |
- Class simDeviceSetClass = FindClassByName(@"SimDeviceSet"); |
- id deviceSet = |
- [simDeviceSetClass setForSetPath:[simDeviceSetClass defaultSetPath]]; |
- for (id simDevice in [deviceSet availableDevices]) { |
- NSString* deviceInfo = |
- [NSString stringWithFormat:@" -d '%@' -s '%@'\n", |
- [simDevice name], [[simDevice runtime] versionString]]; |
- printf("%s", [deviceInfo UTF8String]); |
- } |
-#endif // IOSSIM_USE_XCODE_6 |
- } else { |
- printf("Supported SDK versions:\n"); |
- Class rootClass = FindClassByName(@"DTiPhoneSimulatorSystemRoot"); |
- for (id root in [rootClass knownRoots]) { |
- printf(" '%s'\n", [[root sdkVersion] UTF8String]); |
- } |
- // This is the list of devices supported on Xcode 5.1.x. |
- printf("Supported devices:\n"); |
- printf(" 'iPhone'\n"); |
- printf(" 'iPhone Retina (3.5-inch)'\n"); |
- printf(" 'iPhone Retina (4-inch)'\n"); |
- printf(" 'iPhone Retina (4-inch 64-bit)'\n"); |
- printf(" 'iPad'\n"); |
- printf(" 'iPad Retina'\n"); |
- printf(" 'iPad Retina (64-bit)'\n"); |
+ printf("Supported device/SDK combinations:\n"); |
+ Class simDeviceSetClass = FindClassByName(@"SimDeviceSet"); |
+ id deviceSet = |
+ [simDeviceSetClass setForSetPath:[simDeviceSetClass defaultSetPath]]; |
+ for (id simDevice in [deviceSet availableDevices]) { |
+ NSString* deviceInfo = |
+ [NSString stringWithFormat:@" -d '%@' -s '%@'\n", |
+ [simDevice name], [[simDevice runtime] versionString]]; |
+ printf("%s", [deviceInfo UTF8String]); |
} |
} |
} // namespace |
@@ -312,21 +242,15 @@ void PrintSupportedDevices() { |
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; |
NSFileHandle* simio = [NSFileHandle fileHandleForReadingAtPath:stdioPath_]; |
- if (IsRunningWithXcode6OrLater()) { |
-#if defined(IOSSIM_USE_XCODE_6) |
- // With iOS 8 simulators on Xcode 6, the app output is relative to the |
- // simulator's data directory. |
- NSString* versionString = |
- [[[session sessionConfig] simulatedSystemRoot] sdkVersion]; |
- NSInteger majorVersion = [[[versionString componentsSeparatedByString:@"."] |
- objectAtIndex:0] intValue]; |
- if (majorVersion >= 8) { |
- NSString* dataPath = session.sessionConfig.device.dataPath; |
- NSString* appOutput = |
- [dataPath stringByAppendingPathComponent:stdioPath_]; |
- simio = [NSFileHandle fileHandleForReadingAtPath:appOutput]; |
- } |
-#endif // IOSSIM_USE_XCODE_6 |
+ NSString* versionString = |
+ [[[session sessionConfig] simulatedSystemRoot] sdkVersion]; |
+ NSInteger majorVersion = [[[versionString componentsSeparatedByString:@"."] |
+ objectAtIndex:0] intValue]; |
+ if (majorVersion >= 8) { |
+ NSString* dataPath = session.sessionConfig.device.dataPath; |
+ NSString* appOutput = |
+ [dataPath stringByAppendingPathComponent:stdioPath_]; |
+ simio = [NSFileHandle fileHandleForReadingAtPath:appOutput]; |
} |
NSFileHandle* standardOutput = [NSFileHandle fileHandleWithStandardOutput]; |
// Copy data to stdout/stderr while the app is running. |
@@ -477,19 +401,9 @@ void PrintSupportedDevices() { |
// Otherwise, the iOS Simulator's system logging is sandboxed, so parse the |
// sandboxed system.log file for known errors. |
NSString* path; |
- if (IsRunningWithXcode6OrLater()) { |
-#if defined(IOSSIM_USE_XCODE_6) |
- NSString* dataPath = session.sessionConfig.device.dataPath; |
- path = |
- [dataPath stringByAppendingPathComponent:@"Library/Logs/system.log"]; |
-#endif // IOSSIM_USE_XCODE_6 |
- } else { |
- NSString* relativePathToSystemLog = |
- [NSString stringWithFormat: |
- @"Library/Logs/iOS Simulator/%@/system.log", versionString]; |
- path = [simulatorHome_ |
- stringByAppendingPathComponent:relativePathToSystemLog]; |
- } |
+ NSString* dataPath = session.sessionConfig.device.dataPath; |
+ path = |
+ [dataPath stringByAppendingPathComponent:@"Library/Logs/system.log"]; |
NSFileManager* fileManager = [NSFileManager defaultManager]; |
if ([fileManager fileExistsAtPath:path]) { |
NSString* content = |
@@ -586,22 +500,16 @@ NSBundle* LoadSimulatorFramework(NSString* developerDir) { |
// The path within the developer dir of the private Simulator frameworks. |
NSString* simulatorFrameworkRelativePath; |
- if (IsRunningWithXcode6OrLater()) { |
- simulatorFrameworkRelativePath = |
- @"../SharedFrameworks/DVTiPhoneSimulatorRemoteClient.framework"; |
- NSString* const kCoreSimulatorRelativePath = |
- @"Library/PrivateFrameworks/CoreSimulator.framework"; |
- NSString* coreSimulatorPath = [developerDir |
- stringByAppendingPathComponent:kCoreSimulatorRelativePath]; |
- NSBundle* coreSimulatorBundle = |
- [NSBundle bundleWithPath:coreSimulatorPath]; |
- if (![coreSimulatorBundle load]) |
- return nil; |
- } else { |
- simulatorFrameworkRelativePath = |
- @"Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/" |
- @"DVTiPhoneSimulatorRemoteClient.framework"; |
- } |
+ simulatorFrameworkRelativePath = |
+ @"../SharedFrameworks/DVTiPhoneSimulatorRemoteClient.framework"; |
+ NSString* const kCoreSimulatorRelativePath = |
+ @"Library/PrivateFrameworks/CoreSimulator.framework"; |
+ NSString* coreSimulatorPath = [developerDir |
+ stringByAppendingPathComponent:kCoreSimulatorRelativePath]; |
+ NSBundle* coreSimulatorBundle = |
+ [NSBundle bundleWithPath:coreSimulatorPath]; |
+ if (![coreSimulatorBundle load]) |
+ return nil; |
NSString* simBundlePath = [developerDir |
stringByAppendingPathComponent:simulatorFrameworkRelativePath]; |
NSBundle* simBundle = [NSBundle bundleWithPath:simBundlePath]; |
@@ -633,7 +541,6 @@ DTiPhoneSimulatorApplicationSpecifier* BuildAppSpec(NSString* appPath) { |
// valid. |
DTiPhoneSimulatorSystemRoot* BuildSystemRoot(NSString* sdkVersion) { |
Class systemRootClass = FindClassByName(@"DTiPhoneSimulatorSystemRoot"); |
-#if defined(IOSSIM_USE_XCODE_6) |
Class simRuntimeClass = FindClassByName(@"SimRuntime"); |
NSArray* sorted = |
[[simRuntimeClass supportedRuntimes] sortedArrayUsingDescriptors:@[ |
@@ -642,9 +549,6 @@ DTiPhoneSimulatorSystemRoot* BuildSystemRoot(NSString* sdkVersion) { |
NSString* versionString = [[sorted lastObject] versionString]; |
DTiPhoneSimulatorSystemRoot* systemRoot = |
[systemRootClass rootWithSDKVersion:versionString]; |
-#else |
- DTiPhoneSimulatorSystemRoot* systemRoot = [systemRootClass defaultRoot]; |
-#endif |
if (sdkVersion) |
systemRoot = [systemRootClass rootWithSDKVersion:sdkVersion]; |
@@ -674,47 +578,43 @@ DTiPhoneSimulatorSessionConfig* BuildSessionConfig( |
sessionConfig.simulatedDeviceInfoName = deviceName; |
sessionConfig.simulatedDeviceFamily = deviceFamily; |
- if (IsRunningWithXcode6OrLater()) { |
-#if defined(IOSSIM_USE_XCODE_6) |
- Class simDeviceTypeClass = FindClassByName(@"SimDeviceType"); |
- id simDeviceType = |
- [simDeviceTypeClass supportedDeviceTypesByAlias][deviceName]; |
- Class simRuntimeClass = FindClassByName(@"SimRuntime"); |
- NSString* identifier = systemRoot.runtime.identifier; |
- id simRuntime = [simRuntimeClass supportedRuntimesByIdentifier][identifier]; |
- |
- // Attempt to use an existing device, but create one if a suitable match |
- // can't be found. For example, if the simulator is running with a |
- // non-default home directory (e.g. via iossim's -u command line arg) then |
- // there won't be any devices so one will have to be created. |
- Class simDeviceSetClass = FindClassByName(@"SimDeviceSet"); |
- id deviceSet = |
- [simDeviceSetClass setForSetPath:[simDeviceSetClass defaultSetPath]]; |
- id simDevice = nil; |
- for (id device in [deviceSet availableDevices]) { |
- if ([device runtime] == simRuntime && |
- [device deviceType] == simDeviceType) { |
- simDevice = device; |
- break; |
- } |
+ Class simDeviceTypeClass = FindClassByName(@"SimDeviceType"); |
+ id simDeviceType = |
+ [simDeviceTypeClass supportedDeviceTypesByAlias][deviceName]; |
+ Class simRuntimeClass = FindClassByName(@"SimRuntime"); |
+ NSString* identifier = systemRoot.runtime.identifier; |
+ id simRuntime = [simRuntimeClass supportedRuntimesByIdentifier][identifier]; |
+ |
+ // Attempt to use an existing device, but create one if a suitable match |
+ // can't be found. For example, if the simulator is running with a |
+ // non-default home directory (e.g. via iossim's -u command line arg) then |
+ // there won't be any devices so one will have to be created. |
+ Class simDeviceSetClass = FindClassByName(@"SimDeviceSet"); |
+ id deviceSet = |
+ [simDeviceSetClass setForSetPath:[simDeviceSetClass defaultSetPath]]; |
+ id simDevice = nil; |
+ for (id device in [deviceSet availableDevices]) { |
+ if ([device runtime] == simRuntime && |
+ [device deviceType] == simDeviceType) { |
+ simDevice = device; |
+ break; |
} |
- if (!simDevice) { |
- NSError* error = nil; |
- // n.b. only the device name is necessary because the iOS Simulator menu |
- // already splits devices by runtime version. |
- NSString* name = [NSString stringWithFormat:@"iossim - %@ ", deviceName]; |
- simDevice = [deviceSet createDeviceWithType:simDeviceType |
- runtime:simRuntime |
- name:name |
- error:&error]; |
- if (error) { |
- LogError(@"Failed to create device: %@", error); |
- exit(kExitInitializationFailure); |
- } |
+ } |
+ if (!simDevice) { |
+ NSError* error = nil; |
+ // n.b. only the device name is necessary because the iOS Simulator menu |
+ // already splits devices by runtime version. |
+ NSString* name = [NSString stringWithFormat:@"iossim - %@ ", deviceName]; |
+ simDevice = [deviceSet createDeviceWithType:simDeviceType |
+ runtime:simRuntime |
+ name:name |
+ error:&error]; |
+ if (error) { |
+ LogError(@"Failed to create device: %@", error); |
+ exit(kExitInitializationFailure); |
} |
- sessionConfig.device = simDevice; |
-#endif // IOSSIM_USE_XCODE_6 |
} |
+ sessionConfig.device = simDevice; |
return sessionConfig; |
} |
@@ -795,16 +695,6 @@ BOOL InitializeSimulatorUserHome(NSString* userHomePath) { |
return YES; |
} |
-// Performs a case-insensitive search to see if |stringToSearch| begins with |
-// |prefixToFind|. Returns true if a match is found. |
-BOOL CaseInsensitivePrefixSearch(NSString* stringToSearch, |
- NSString* prefixToFind) { |
- NSStringCompareOptions options = (NSAnchoredSearch | NSCaseInsensitiveSearch); |
- NSRange range = [stringToSearch rangeOfString:prefixToFind |
- options:options]; |
- return range.location != NSNotFound; |
-} |
- |
// Prints the usage information to stderr. |
void PrintUsage() { |
fprintf(stderr, "Usage: iossim [-d device] [-s sdkVersion] [-u homeDir] " |
@@ -828,20 +718,9 @@ void PrintUsage() { |
} |
} // namespace |
-void EnsureSupportForCurrentXcodeVersion() { |
- if (IsRunningWithXcode6OrLater()) { |
-#if !IOSSIM_USE_XCODE_6 |
- LogError(@"Running on Xcode 6, but Xcode 6 support was not compiled in."); |
- exit(kExitUnsupportedXcodeVersion); |
-#endif // IOSSIM_USE_XCODE_6 |
- } |
-} |
- |
int main(int argc, char* const argv[]) { |
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; |
- EnsureSupportForCurrentXcodeVersion(); |
- |
// basename() may modify the passed in string and it returns a pointer to an |
// internal buffer. Give it a copy to modify, and copy what it returns. |
char* worker = strdup(argv[0]); |
@@ -857,8 +736,7 @@ int main(int argc, char* const argv[]) { |
NSString* appPath = nil; |
NSString* appName = nil; |
NSString* sdkVersion = nil; |
- NSString* deviceName = |
- IsRunningWithXcode6OrLater() ? @"iPhone 5s" : @"iPhone"; |
+ NSString* deviceName = @"iPhone 5s"; |
NSString* simHomePath = nil; |
NSMutableArray* appArgs = [NSMutableArray array]; |
NSMutableDictionary* appEnv = [NSMutableDictionary dictionary]; |
@@ -965,26 +843,11 @@ int main(int argc, char* const argv[]) { |
// Determine the deviceFamily based on the deviceName |
NSNumber* deviceFamily = nil; |
- if (IsRunningWithXcode6OrLater()) { |
-#if defined(IOSSIM_USE_XCODE_6) |
- Class simDeviceTypeClass = FindClassByName(@"SimDeviceType"); |
- if ([simDeviceTypeClass supportedDeviceTypesByAlias][deviceName] == nil) { |
- LogError(@"Invalid device name: %@.", deviceName); |
- PrintSupportedDevices(); |
- exit(kExitInvalidArguments); |
- } |
-#endif // IOSSIM_USE_XCODE_6 |
- } else { |
- if (!deviceName || CaseInsensitivePrefixSearch(deviceName, @"iPhone")) { |
- deviceFamily = [NSNumber numberWithInt:kIPhoneFamily]; |
- } else if (CaseInsensitivePrefixSearch(deviceName, @"iPad")) { |
- deviceFamily = [NSNumber numberWithInt:kIPadFamily]; |
- } |
- else { |
- LogError(@"Invalid device name: %@. Must begin with 'iPhone' or 'iPad'", |
- deviceName); |
- exit(kExitInvalidArguments); |
- } |
+ Class simDeviceTypeClass = FindClassByName(@"SimDeviceType"); |
+ if ([simDeviceTypeClass supportedDeviceTypesByAlias][deviceName] == nil) { |
+ LogError(@"Invalid device name: %@.", deviceName); |
+ PrintSupportedDevices(); |
+ exit(kExitInvalidArguments); |
} |
// Set up the user home directory for the simulator only if a non-default |