Index: testing/iossim/iossim.mm |
diff --git a/testing/iossim/iossim.mm b/testing/iossim/iossim.mm |
index 152f2bea4c74d43143aa805ceafa16d4059a899a..b6108e501b6d4e70567cc3bf5d83c44752ec12cf 100644 |
--- a/testing/iossim/iossim.mm |
+++ b/testing/iossim/iossim.mm |
@@ -28,6 +28,19 @@ |
@class DTiPhoneSimulatorSession; |
@class DTiPhoneSimulatorSessionConfig; |
@class DTiPhoneSimulatorSystemRoot; |
+@class DVTiPhoneSimulatorMessenger; |
+ |
+@interface DVTPlatform : NSObject |
++ (BOOL)loadAllPlatformsReturningError:(id *)arg1; |
+@end |
+ |
+@protocol OS_dispatch_source |
+@end |
+@protocol OS_dispatch_queue |
+@end |
+@class DVTDispatchLock; |
+@class DVTConfinementServiceConnection; |
+@class DVTTask; |
@protocol DTiPhoneSimulatorSessionDelegate |
- (void)session:(DTiPhoneSimulatorSession*)session |
@@ -37,7 +50,7 @@ |
withError:(NSError*)error; |
@end |
-#import "iPhoneSimulatorRemoteClient.h" |
+#import "DVTiPhoneSimulatorRemoteClient.h" |
// An undocumented system log key included in messages from launchd. The value |
// is the PID of the process the message is about (as opposed to launchd's PID). |
@@ -73,7 +86,9 @@ const NSTimeInterval kOutputPollIntervalSeconds = 0.1; |
// The path within the developer dir of the private Simulator frameworks. |
NSString* const kSimulatorFrameworkRelativePath = |
@"Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/" |
- @"iPhoneSimulatorRemoteClient.framework"; |
+ @"DVTiPhoneSimulatorRemoteClient.framework"; |
+NSString* const kDVTFoundationRelativePath = |
+ @"../SharedFrameworks/DVTFoundation.framework"; |
NSString* const kDevToolsFoundationRelativePath = |
@"../OtherFrameworks/DevToolsFoundation.framework"; |
NSString* const kSimulatorRelativePath = |
@@ -300,9 +315,12 @@ void LogWarning(NSString* format, ...) { |
aslmsg query = asl_new(ASL_TYPE_QUERY); |
asl_set_query(query, ASL_KEY_SENDER, "launchd", |
ASL_QUERY_OP_EQUAL | ASL_QUERY_OP_SUBSTRING); |
- asl_set_query(query, ASL_KEY_REF_PID, |
- [[[session simulatedApplicationPID] stringValue] UTF8String], |
- ASL_QUERY_OP_EQUAL); |
+ asl_set_query( |
+ query, |
+ ASL_KEY_REF_PID, |
+ [[NSString stringWithFormat:@"%d", [session simulatedApplicationPID]] |
lliabraa
2013/12/12 15:01:15
why change from stringValue to stringWithFormat?
justincohen
2013/12/12 15:02:03
Because it's not a NSNumber anymore, it's an int.
TVL
2013/12/12 16:08:27
This whole thing would be less scary with a char[2
justincohen
2013/12/16 18:44:37
Done, converted to snprintf.
On 2013/12/12 16:08:
|
+ UTF8String], |
+ ASL_QUERY_OP_EQUAL); |
asl_set_query(query, ASL_KEY_TIME, "-1m", ASL_QUERY_OP_GREATER_EQUAL); |
// Log any messages found, and take note of any messages that may indicate |
@@ -393,16 +411,38 @@ NSString* FindDeveloperDir() { |
return output; |
} |
+// Helper to find a class by name and die if it isn't found. |
TVL
2013/12/12 16:08:27
any reason this got moved?
justincohen
2013/12/16 18:44:37
Forward declaration.
On 2013/12/12 16:08:27, TVL
|
+Class FindClassByName(NSString* nameOfClass) { |
+ Class theClass = NSClassFromString(nameOfClass); |
+ if (!theClass) { |
+ LogError(@"Failed to find class %@ at runtime.", nameOfClass); |
+ exit(kExitInitializationFailure); |
+ } |
+ return theClass; |
+} |
+ |
// Loads the Simulator framework from the given developer dir. |
NSBundle* LoadSimulatorFramework(NSString* developerDir) { |
// The Simulator framework depends on some of the other Xcode private |
// frameworks; manually load them first so everything can be linked up. |
+ NSString* dvtFoundationPath = [developerDir |
+ stringByAppendingPathComponent:kDVTFoundationRelativePath]; |
+ NSBundle* dvtFoundationBundle = |
+ [NSBundle bundleWithPath:dvtFoundationPath]; |
+ if (![dvtFoundationBundle load]) |
+ return nil; |
+ |
NSString* devToolsFoundationPath = [developerDir |
stringByAppendingPathComponent:kDevToolsFoundationRelativePath]; |
NSBundle* devToolsFoundationBundle = |
[NSBundle bundleWithPath:devToolsFoundationPath]; |
if (![devToolsFoundationBundle load]) |
return nil; |
+ |
+ // Prime DVTPlatform. |
+ Class DVTPlatformClass = FindClassByName(@"DVTPlatform"); |
+ [DVTPlatformClass loadAllPlatformsReturningError:nil]; |
TVL
2013/12/12 16:08:27
You should check the bool return result, and would
justincohen
2013/12/16 18:44:37
Done.
|
+ |
NSString* simBundlePath = [developerDir |
stringByAppendingPathComponent:kSimulatorFrameworkRelativePath]; |
NSBundle* simBundle = [NSBundle bundleWithPath:simBundlePath]; |
@@ -411,16 +451,6 @@ NSBundle* LoadSimulatorFramework(NSString* developerDir) { |
return simBundle; |
} |
-// Helper to find a class by name and die if it isn't found. |
-Class FindClassByName(NSString* nameOfClass) { |
- Class theClass = NSClassFromString(nameOfClass); |
- if (!theClass) { |
- LogError(@"Failed to find class %@ at runtime.", nameOfClass); |
- exit(kExitInitializationFailure); |
- } |
- return theClass; |
-} |
- |
// Converts the given app path to an application spec, which requires an |
// absolute path. |
DTiPhoneSimulatorApplicationSpecifier* BuildAppSpec(NSString* appPath) { |
@@ -454,7 +484,8 @@ DTiPhoneSimulatorSessionConfig* BuildSessionConfig( |
NSString* stderrPath, |
NSArray* appArgs, |
NSDictionary* appEnv, |
- NSNumber* deviceFamily) { |
+ NSNumber* deviceFamily, |
+ NSString* deviceName) { |
Class sessionConfigClass = FindClassByName(@"DTiPhoneSimulatorSessionConfig"); |
DTiPhoneSimulatorSessionConfig* sessionConfig = |
[[[sessionConfigClass alloc] init] autorelease]; |
@@ -465,6 +496,7 @@ DTiPhoneSimulatorSessionConfig* BuildSessionConfig( |
sessionConfig.simulatedApplicationStdOutPath = stdoutPath; |
sessionConfig.simulatedApplicationLaunchArgs = appArgs; |
sessionConfig.simulatedApplicationLaunchEnvironment = appEnv; |
+ sessionConfig.simulatedDeviceInfoName = deviceName; |
sessionConfig.simulatedDeviceFamily = deviceFamily; |
return sessionConfig; |
} |
@@ -529,18 +561,10 @@ BOOL CreateHomeDirSubDirs(NSString* userHomePath) { |
// path, then sets the path in the appropriate environment variable. |
// Returns YES if successful, NO if unable to create or initialize the given |
// directory. |
-BOOL InitializeSimulatorUserHome(NSString* userHomePath, NSString* deviceName) { |
+BOOL InitializeSimulatorUserHome(NSString* userHomePath) { |
if (!CreateHomeDirSubDirs(userHomePath)) |
return NO; |
- // Set the device to simulate. Note that the iOS Simulator must not be running |
- // for this setting to take effect. |
- CFStringRef iPhoneSimulatorAppID = CFSTR("com.apple.iphonesimulator"); |
- CFPreferencesSetAppValue(CFSTR("SimulateDevice"), |
- deviceName, |
- iPhoneSimulatorAppID); |
- CFPreferencesAppSynchronize(iPhoneSimulatorAppID); |
- |
// Update the environment to use the specified directory as the user home |
// directory. |
// Note: the third param of setenv specifies whether or not to overwrite the |
@@ -728,7 +752,7 @@ int main(int argc, char* const argv[]) { |
exit(kExitInitializationFailure); |
} |
} |
- if (!InitializeSimulatorUserHome(simHomePath, deviceName)) { |
+ if (!InitializeSimulatorUserHome(simHomePath)) { |
LogError(@"Unable to initialize home directory for simulator: %@", |
simHomePath); |
exit(kExitInitializationFailure); |
@@ -741,7 +765,8 @@ int main(int argc, char* const argv[]) { |
stdioPath, |
appArgs, |
appEnv, |
- deviceFamily); |
+ deviceFamily, |
+ deviceName); |
SimulatorDelegate* delegate = |
[[[SimulatorDelegate alloc] initWithStdioPath:stdioPath |
developerDir:developerDir |