From 5357b457f5d858768451ccbf253a0938bde3e80d Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Mon, 10 Mar 2014 21:28:47 -0700 Subject: [PATCH 1/3] Changes from downstream appcelerator/ios-sim to support the new PrivateFrameworks for iPhoneSimulator --- .../DVTiPhoneSimulatorRemoteClient.h | 290 ++++++++++++++++++ Source/iPhoneSimulator.h | 2 +- Source/iPhoneSimulator.m | 109 ++++++- .../iPhoneSimulatorRemoteClient.h | 124 -------- ios-sim.xcconfig | 11 - ios-sim.xcodeproj/project.pbxproj | 6 +- .../xcshareddata/xcschemes/ios-sim.xcscheme | 2 +- 7 files changed, 396 insertions(+), 148 deletions(-) create mode 100644 DVTiPhoneSimulatorRemoteClient/DVTiPhoneSimulatorRemoteClient.h delete mode 100644 iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h delete mode 100644 ios-sim.xcconfig diff --git a/DVTiPhoneSimulatorRemoteClient/DVTiPhoneSimulatorRemoteClient.h b/DVTiPhoneSimulatorRemoteClient/DVTiPhoneSimulatorRemoteClient.h new file mode 100644 index 0000000..70cc4ac --- /dev/null +++ b/DVTiPhoneSimulatorRemoteClient/DVTiPhoneSimulatorRemoteClient.h @@ -0,0 +1,290 @@ +// +// Generated by class-dump 3.5 (64 bit). +// +// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. +// + +#pragma mark Blocks + +typedef void (^CDUnknownBlockType)(void); // return type and parameters are unknown + +#pragma mark - + +// +// File: $(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/DVTiPhoneSimulatorRemoteClient.framework/Versions/A/DVTiPhoneSimulatorRemoteClient +// +// Arch: x86_64 +// Current version: 12.0.0 +// Compatibility version: 1.0.0 +// Source version: 5037.3.0.0.0 +// Minimum Mac OS X version: 10.8.0 +// SDK version: 10.9.0 +// +// Objective-C Garbage Collection: Unsupported +// +// Run path: @loader_path/../../../../PrivateFrameworks/ +// = $(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks +// + + +@class DTiPhoneSimulatorApplicationSpecifier; +@class DTiPhoneSimulatorSession; +@class DTiPhoneSimulatorSessionConfig; +@class DTiPhoneSimulatorSystemRoot; +@class DVTiPhoneSimulatorMessenger; + +@protocol DTiPhoneSimulatorSessionDelegate + +- (void) session: (DTiPhoneSimulatorSession *) session didEndWithError: (NSError *) error; +- (void) session: (DTiPhoneSimulatorSession *) session didStart: (BOOL) started withError: (NSError *) error; + +@end + +@protocol OS_dispatch_source +@end +@protocol OS_dispatch_queue +@end +@class DVTDispatchLock; +@class DVTConfinementServiceConnection; +@class DVTTask; + + +@interface DVTiPhoneSimulatorMessenger : NSObject +{ + DTiPhoneSimulatorSession *_session; + CDUnknownBlockType _readyMessageHandler; + CDUnknownBlockType _runningMessageHandler; + CDUnknownBlockType _appDidLaunchMessageHandler; + CDUnknownBlockType _appDidQuitMessageHandler; + CDUnknownBlockType _appPIDExitedMessageHandler; + CDUnknownBlockType _toolDidLaunchMessageHandler; +} + ++ (id)messengerForSession:(id)arg1 withConnection:(id)arg2; ++ (id)messengerForSession:(id)arg1; +@property(copy, nonatomic) CDUnknownBlockType toolDidLaunchMessageHandler; // @synthesize toolDidLaunchMessageHandler=_toolDidLaunchMessageHandler; +@property(copy, nonatomic) CDUnknownBlockType appPIDExitedMessageHandler; // @synthesize appPIDExitedMessageHandler=_appPIDExitedMessageHandler; +@property(copy, nonatomic) CDUnknownBlockType appDidQuitMessageHandler; // @synthesize appDidQuitMessageHandler=_appDidQuitMessageHandler; +@property(copy, nonatomic) CDUnknownBlockType appDidLaunchMessageHandler; // @synthesize appDidLaunchMessageHandler=_appDidLaunchMessageHandler; +@property(copy, nonatomic) CDUnknownBlockType runningMessageHandler; // @synthesize runningMessageHandler=_runningMessageHandler; +@property(copy, nonatomic) CDUnknownBlockType readyMessageHandler; // @synthesize readyMessageHandler=_readyMessageHandler; +@property(readonly) DTiPhoneSimulatorSession *session; // @synthesize session=_session; +- (void)doUbiquityFetchEvent; +- (void)doFetchEventForPID:(int)arg1; +- (void)backgroundAllApps:(int)arg1; +- (void)startSimulatorToolSessionWithParameters:(id)arg1; +- (void)stopSimulatingLocation; +- (void)startSimulatingLocationWithLatitude:(id)arg1 longitute:(id)arg2; +- (void)endSimulatorSessionWithPID:(int)arg1; +- (void)startSimulatorSessionWithRequestInfo:(id)arg1; +- (void)clearAllMessageHandlers; +- (void)waitPID:(int)arg1 withAppPIDExitedMessagedHandler:(CDUnknownBlockType)arg2; +- (void)disconnectFromService; +- (BOOL)connectToServiceWithSessionOnLaunch:(BOOL)arg1 simulatorPID:(int *)arg2 error:(id *)arg3; +- (id)initWithSession:(id)arg1; + +@end + +@interface DVTiPhoneSimulatorLocalMessenger : DVTiPhoneSimulatorMessenger +{ + BOOL _appTerminationMessageSent; + NSObject *_pidDispatchSource; + DVTTask *_simTask; +} + +- (void)doUbiquityFetchEvent; +- (void)doFetchEventForPID:(int)arg1; +- (void)backgroundAllApps:(int)arg1; +- (void)_handleSimulatorToolDidLaunchMessage:(id)arg1; +- (void)setToolDidLaunchMessageHandler:(CDUnknownBlockType)arg1; +- (void)waitPID:(int)arg1 withAppPIDExitedMessagedHandler:(CDUnknownBlockType)arg2; +- (void)_handleSimulatorAppDidQuitMessage:(id)arg1; +- (void)setAppDidQuitMessageHandler:(CDUnknownBlockType)arg1; +- (void)_handleSimulatorAppDidLaunchMessage:(id)arg1; +- (void)setAppDidLaunchMessageHandler:(CDUnknownBlockType)arg1; +- (void)_handleSimulatorRunningMessage:(id)arg1; +- (void)setRunningMessageHandler:(CDUnknownBlockType)arg1; +- (void)_handleSimulatorReadyMessage:(id)arg1; +- (void)setReadyMessageHandler:(CDUnknownBlockType)arg1; +- (void)startSimulatorToolSessionWithParameters:(id)arg1; +- (void)stopSimulatingLocation; +- (void)startSimulatingLocationWithLatitude:(id)arg1 longitute:(id)arg2; +- (void)endSimulatorSessionWithPID:(int)arg1; +- (void)startSimulatorSessionWithRequestInfo:(id)arg1; +- (void)clearAllMessageHandlers; +- (void)disconnectFromService; +- (BOOL)connectToServiceWithSessionOnLaunch:(BOOL)arg1 simulatorPID:(int *)arg2 error:(id *)arg3; +- (void)_enableObserver:(BOOL)arg1 forName:(id)arg2 selector:(SEL)arg3; + +@end + +@interface DVTiPhoneSimulatorRemoteMessenger : DVTiPhoneSimulatorMessenger +{ + unsigned long long _commandTag; + NSObject *_responseQueue; + DVTDispatchLock *_awaitingLock; + NSMutableDictionary *_awaitingSemaphores; + NSMutableDictionary *_awaitingResponses; + NSMutableSet *_waitingAppPIDs; + DVTConfinementServiceConnection *_connection; +} + +@property(readonly) DVTConfinementServiceConnection *connection; // @synthesize connection=_connection; +- (void)handleNotificationResponse:(id)arg1; +- (void)waitPID:(int)arg1 withAppPIDExitedMessagedHandler:(CDUnknownBlockType)arg2; +- (void)startSimulatorToolSessionWithParameters:(id)arg1; +- (void)stopSimulatingLocation; +- (void)startSimulatingLocationWithLatitude:(id)arg1 longitute:(id)arg2; +- (void)endSimulatorSessionWithPID:(int)arg1; +- (void)startSimulatorSessionWithRequestInfo:(id)arg1; +- (void)disconnectFromService; +- (BOOL)connectToServiceWithSessionOnLaunch:(BOOL)arg1 simulatorPID:(int *)arg2 error:(id *)arg3; +- (BOOL)sendTaggedRequest:(id)arg1 awaitingResponse:(id *)arg2 error:(id *)arg3; +- (id)nextCommandTag; +- (id)awaitResponseWithTag:(id)arg1 error:(id *)arg2; +- (void)enqueueResponse:(id)arg1 withTag:(id)arg2 error:(id)arg3; +- (BOOL)sendRequest:(id)arg1 withTag:(id)arg2 error:(id *)arg3; +- (id)initWithSession:(id)arg1 connection:(id)arg2; + +@end + +@interface DTiPhoneSimulatorSession : NSObject +{ + int _simulatedApplicationPID; + int _simulatorPID; + NSString *_uuid; + id _delegate; + NSString *_simulatedAppPath; + long long _sessionLifecycleProgress; + NSTimer *_timeoutTimer; + DTiPhoneSimulatorSessionConfig *_sessionConfig; + DVTiPhoneSimulatorMessenger *_messenger; +} + +@property(retain) DVTiPhoneSimulatorMessenger *messenger; // @synthesize messenger=_messenger; +@property(copy, nonatomic) DTiPhoneSimulatorSessionConfig *sessionConfig; // @synthesize sessionConfig=_sessionConfig; +@property(retain, nonatomic) NSTimer *timeoutTimer; // @synthesize timeoutTimer=_timeoutTimer; +@property(nonatomic) long long sessionLifecycleProgress; // @synthesize sessionLifecycleProgress=_sessionLifecycleProgress; +@property int simulatorPID; // @synthesize simulatorPID=_simulatorPID; +@property(copy) NSString *simulatedAppPath; // @synthesize simulatedAppPath=_simulatedAppPath; +@property int simulatedApplicationPID; // @synthesize simulatedApplicationPID=_simulatedApplicationPID; +@property(retain, nonatomic) id delegate; // @synthesize delegate=_delegate; +@property(copy, nonatomic) NSString *uuid; // @synthesize uuid=_uuid; +- (void)doUbiquityFetchEvent; +- (void)doFetchEventForPID:(int)arg1; +- (void)backgroundAllApps:(int)arg1; +- (id)_invalidConfigError; +- (void)_endSimulatorSession; +- (void)_callDelegateResponseFromSessionEndedInfo:(id)arg1; +- (void)_callDelegateResponseFromSessionStartedInfo:(id)arg1; +- (id)_sessionStartRequestInfoFromConfig:(id)arg1 withError:(id *)arg2; +- (BOOL)_startToolSessionInSimulatorWithError:(id *)arg1; +- (BOOL)_startApplicationSessionInSimulatorWithError:(id *)arg1; +- (BOOL)_startBasicSessionInSimulatorWithError:(id *)arg1; +- (BOOL)_startSessionInSimulatorWithError:(id *)arg1; +- (BOOL)_handleSessionEndedInSimulator:(id)arg1 notification:(id)arg2; +- (void)_handleSessionStartedWithSim:(id)arg1; +- (void)_handleSessionStartedInSimulator:(id)arg1; +- (void)_handleSimulatorReadyMessage:(id)arg1; +- (void)_timeoutElapsed:(id)arg1; +- (BOOL)attachedToTargetWithConfig:(id)arg1 error:(id *)arg2; +- (void)stopLocationSimulation; +- (void)simulateLocationWithLatitude:(id)arg1 longitude:(id)arg2; +- (void)requestEndWithTimeout:(double)arg1; +- (BOOL)requestStartWithConfig:(id)arg1 timeout:(double)arg2 error:(id *)arg3; +- (BOOL)_setUpSimulatorMessengerWithConfig:(id)arg1 error:(id *)arg2; +- (id)description; +- (void)dealloc; +- (id)init; + +@end + +@interface DTiPhoneSimulatorSessionConfig : NSObject +{ + BOOL _launchForBackgroundFetch; + BOOL _simulatedApplicationShouldWaitForDebugger; + NSString *_localizedClientName; + DTiPhoneSimulatorSystemRoot *_simulatedSystemRoot; + NSString *_simulatedDeviceInfoName; + NSNumber *_simulatedDeviceFamily; + NSString *_simulatedArchitecture; + NSNumber *_simulatedDisplayHeight; + NSNumber *_simulatedDisplayScale; + DTiPhoneSimulatorApplicationSpecifier *_applicationToSimulateOnStart; + NSNumber *_pid; + NSArray *_simulatedApplicationLaunchArgs; + NSDictionary *_simulatedApplicationLaunchEnvironment; + NSString *_simulatedApplicationStdOutPath; + NSString *_simulatedApplicationStdErrPath; + NSFileHandle *_stdinFileHandle; + NSFileHandle *_stdoutFileHandle; + NSFileHandle *_stderrFileHandle; + id _confinementService; +} + ++ (id)displayNameForDeviceFamily:(id)arg1; +@property(retain) id confinementService; // @synthesize confinementService=_confinementService; +@property(retain) NSFileHandle *stderrFileHandle; // @synthesize stderrFileHandle=_stderrFileHandle; +@property(retain) NSFileHandle *stdoutFileHandle; // @synthesize stdoutFileHandle=_stdoutFileHandle; +@property(retain) NSFileHandle *stdinFileHandle; // @synthesize stdinFileHandle=_stdinFileHandle; +@property(copy) NSString *simulatedApplicationStdErrPath; // @synthesize simulatedApplicationStdErrPath=_simulatedApplicationStdErrPath; +@property(copy) NSString *simulatedApplicationStdOutPath; // @synthesize simulatedApplicationStdOutPath=_simulatedApplicationStdOutPath; +@property BOOL simulatedApplicationShouldWaitForDebugger; // @synthesize simulatedApplicationShouldWaitForDebugger=_simulatedApplicationShouldWaitForDebugger; +@property(copy) NSDictionary *simulatedApplicationLaunchEnvironment; // @synthesize simulatedApplicationLaunchEnvironment=_simulatedApplicationLaunchEnvironment; +@property(copy) NSArray *simulatedApplicationLaunchArgs; // @synthesize simulatedApplicationLaunchArgs=_simulatedApplicationLaunchArgs; +@property(copy) NSNumber *pid; // @synthesize pid=_pid; +@property(copy) DTiPhoneSimulatorApplicationSpecifier *applicationToSimulateOnStart; // @synthesize applicationToSimulateOnStart=_applicationToSimulateOnStart; +@property(copy) NSNumber *simulatedDisplayScale; // @synthesize simulatedDisplayScale=_simulatedDisplayScale; +@property(copy) NSNumber *simulatedDisplayHeight; // @synthesize simulatedDisplayHeight=_simulatedDisplayHeight; +@property(copy) NSString *simulatedArchitecture; // @synthesize simulatedArchitecture=_simulatedArchitecture; +@property(copy) NSNumber *simulatedDeviceFamily; // @synthesize simulatedDeviceFamily=_simulatedDeviceFamily; +@property(retain) NSString *simulatedDeviceInfoName; // @synthesize simulatedDeviceInfoName=_simulatedDeviceInfoName; +@property(copy) DTiPhoneSimulatorSystemRoot *simulatedSystemRoot; // @synthesize simulatedSystemRoot=_simulatedSystemRoot; +@property(copy) NSString *localizedClientName; // @synthesize localizedClientName=_localizedClientName; +@property BOOL launchForBackgroundFetch; // @synthesize launchForBackgroundFetch=_launchForBackgroundFetch; +- (id)description; +- (id)copyWithZone:(struct _NSZone *)arg1; +- (id)init; + +@end + +@interface DTiPhoneSimulatorSystemRoot : NSObject +{ + NSString *sdkRootPath; + NSString *sdkVersion; + NSString *sdkDisplayName; +} + ++ (id)rootWithSDKVersion:(id)arg1; ++ (id)rootWithSDKPath:(id)arg1; ++ (id)defaultRoot; ++ (id)knownRoots; ++ (void)initialize; +@property(copy) NSString *sdkDisplayName; // @synthesize sdkDisplayName; +@property(copy) NSString *sdkVersion; // @synthesize sdkVersion; +@property(copy) NSString *sdkRootPath; // @synthesize sdkRootPath; +- (id)description; +- (long long)compare:(id)arg1; +- (id)copyWithZone:(struct _NSZone *)arg1; +- (BOOL)isEqual:(id)arg1; +- (id)initWithSDKPath:(id)arg1; + +@end + +@interface DTiPhoneSimulatorApplicationSpecifier : NSObject +{ + NSString *appPath; + NSString *bundleID; + NSString *toolPath; +} + ++ (id)specifierWithToolPath:(id)arg1; ++ (id)specifierWithApplicationBundleIdentifier:(id)arg1; ++ (id)specifierWithApplicationPath:(id)arg1; +@property(copy, nonatomic) NSString *toolPath; // @synthesize toolPath; +@property(copy, nonatomic) NSString *bundleID; // @synthesize bundleID; +@property(copy, nonatomic) NSString *appPath; // @synthesize appPath; +- (id)description; +- (id)copyWithZone:(struct _NSZone *)arg1; + +@end \ No newline at end of file diff --git a/Source/iPhoneSimulator.h b/Source/iPhoneSimulator.h index 0181e1c..92d7985 100644 --- a/Source/iPhoneSimulator.h +++ b/Source/iPhoneSimulator.h @@ -6,7 +6,7 @@ */ #import -#import +#import #import "version.h" @interface iPhoneSimulator : NSObject { diff --git a/Source/iPhoneSimulator.m b/Source/iPhoneSimulator.m index bf81765..62f4d79 100644 --- a/Source/iPhoneSimulator.m +++ b/Source/iPhoneSimulator.m @@ -10,6 +10,7 @@ #import "nsprintf.h" #import #import +@class DTiPhoneSimulatorSystemRoot; NSString *simulatorPrefrencesName = @"com.apple.iphonesimulator"; NSString *deviceProperty = @"SimulateDevice"; @@ -19,11 +20,100 @@ NSString *deviceIpad = @"iPad"; NSString *deviceIpadRetina = @"iPad (Retina)"; +// The path within the developer dir of the private Simulator frameworks. +NSString* const kSimulatorFrameworkRelativePath = @"Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/DVTiPhoneSimulatorRemoteClient.framework"; +NSString* const kDVTFoundationRelativePath = @"../SharedFrameworks/DVTFoundation.framework"; +NSString* const kDevToolsFoundationRelativePath = @"../OtherFrameworks/DevToolsFoundation.framework"; +NSString* const kSimulatorRelativePath = @"Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app"; + + +@interface DVTPlatform : NSObject ++ (BOOL)loadAllPlatformsReturningError:(id*)arg1; +@end + /** * A simple iPhoneSimulatorRemoteClient framework. */ @implementation iPhoneSimulator +// Helper to find a class by name and die if it isn't found. +-(Class) FindClassByName:(NSString*) nameOfClass { + Class theClass = NSClassFromString(nameOfClass); + if (!theClass) { + nsfprintf(stderr,@"Failed to find class %@ at runtime.", nameOfClass); + exit(EXIT_FAILURE); + } + return theClass; +} + +// Loads the Simulator framework from the given developer dir. +-(void) 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]){ + nsprintf(@"Unable to dvtFoundationBundle. Error: "); + exit(EXIT_FAILURE); + return ; + } + NSString* devToolsFoundationPath = [developerDir stringByAppendingPathComponent:kDevToolsFoundationRelativePath]; + NSBundle* devToolsFoundationBundle = + [NSBundle bundleWithPath:devToolsFoundationPath]; + if (![devToolsFoundationBundle load]){ + nsprintf(@"Unable to devToolsFoundationPath. Error: "); + return ; + } + // Prime DVTPlatform. + NSError* error; + Class DVTPlatformClass = [self FindClassByName:@"DVTPlatform"]; + if (![DVTPlatformClass loadAllPlatformsReturningError:&error]) { + nsprintf(@"Unable to loadAllPlatformsReturningError. Error: %@",[error localizedDescription]); + return ; + } + NSString* simBundlePath = [developerDir stringByAppendingPathComponent:kSimulatorFrameworkRelativePath]; + NSBundle* simBundle = [NSBundle bundleWithPath:simBundlePath]; + if (![simBundle load]){ + nsprintf(@"Unable to load simulator framework. Error: %@",[error localizedDescription]); + return ; + } + return ; +} + + +// Finds the developer dir via xcode-select or the DEVELOPER_DIR environment +// variable. +NSString* FindDeveloperDir() { + // Check the env first. + NSDictionary* env = [[NSProcessInfo processInfo] environment]; + NSString* developerDir = [env objectForKey:@"DEVELOPER_DIR"]; + if ([developerDir length] > 0) + return developerDir; + + // Go look for it via xcode-select. + NSTask* xcodeSelectTask = [[[NSTask alloc] init] autorelease]; + [xcodeSelectTask setLaunchPath:@"/usr/bin/xcode-select"]; + [xcodeSelectTask setArguments:[NSArray arrayWithObject:@"-print-path"]]; + + NSPipe* outputPipe = [NSPipe pipe]; + [xcodeSelectTask setStandardOutput:outputPipe]; + NSFileHandle* outputFile = [outputPipe fileHandleForReading]; + + [xcodeSelectTask launch]; + NSData* outputData = [outputFile readDataToEndOfFile]; + [xcodeSelectTask terminate]; + + NSString* output = + [[[NSString alloc] initWithData:outputData + encoding:NSUTF8StringEncoding] autorelease]; + output = [output stringByTrimmingCharactersInSet: + [NSCharacterSet whitespaceAndNewlineCharacterSet]]; + if ([output length] == 0) + output = nil; + return output; +} - (void) printUsage { fprintf(stderr, "Usage: ios-sim [--args ...]\n"); fprintf(stderr, "\n"); @@ -54,7 +144,9 @@ - (void) printUsage { - (int) showSDKs { - NSArray *roots = [DTiPhoneSimulatorSystemRoot knownRoots]; + Class systemRootClass = [self FindClassByName:@"DTiPhoneSimulatorSystemRoot"]; + + NSArray *roots = [systemRootClass knownRoots]; nsprintf(@"Simulator SDK Roots:"); for (DTiPhoneSimulatorSystemRoot *root in roots) { @@ -95,7 +187,8 @@ - (void)session:(DTiPhoneSimulatorSession *)session didStart:(BOOL)started withE } if (started) { if (shouldStartDebugger) { - char*args[4] = { NULL, NULL, (char*)[[[session simulatedApplicationPID] description] UTF8String], NULL }; + int pid = [session simulatedApplicationPID]; + char*args[4] = { NULL, NULL, (char*)[[@(pid) description] UTF8String], NULL }; if (useGDB) { args[0] = "gdb"; args[1] = "program"; @@ -196,7 +289,7 @@ - (int)launchApp:(NSString *)path withFamily:(NSString *)family } /* Create the app specifier */ - appSpec = startOnly ? nil : [DTiPhoneSimulatorApplicationSpecifier specifierWithApplicationPath:path]; + appSpec = startOnly ? nil : [[self FindClassByName:@"DTiPhoneSimulatorApplicationSpecifier"] specifierWithApplicationPath:path]; if (verbose) { nsprintf(@"App Spec: %@", appSpec); @@ -208,7 +301,7 @@ - (int)launchApp:(NSString *)path withFamily:(NSString *)family } /* Set up the session configuration */ - config = [[[DTiPhoneSimulatorSessionConfig alloc] init] autorelease]; + config = [[[[self FindClassByName:@"DTiPhoneSimulatorSessionConfig"] alloc] init] autorelease]; [config setApplicationToSimulateOnStart:appSpec]; [config setSimulatedSystemRoot:sdkRoot]; [config setSimulatedApplicationShouldWaitForDebugger:shouldStartDebugger]; @@ -252,7 +345,7 @@ - (int)launchApp:(NSString *)path withFamily:(NSString *)family [self changeDeviceType:family retina:retinaDevice isTallDevice:tallDevice]; /* Start the session */ - session = [[[DTiPhoneSimulatorSession alloc] init] autorelease]; + session = [[[[self FindClassByName:@"DTiPhoneSimulatorSession"] alloc] init] autorelease]; [session setDelegate:self]; if (uuid != nil){ [session setUuid:uuid]; @@ -361,7 +454,8 @@ - (void)runWithArgc:(int)argc argv:(char **)argv { else if (strcmp(argv[i], "--sdk") == 0) { i++; NSString* ver = [NSString stringWithCString:argv[i] encoding:NSUTF8StringEncoding]; - NSArray *roots = [DTiPhoneSimulatorSystemRoot knownRoots]; + Class systemRootClass = [self FindClassByName:@"DTiPhoneSimulatorSystemRoot"]; + NSArray *roots = [systemRootClass knownRoots]; for (DTiPhoneSimulatorSystemRoot *root in roots) { NSString *v = [root sdkVersion]; if ([v isEqualToString:ver]) { @@ -424,7 +518,8 @@ - (void)runWithArgc:(int)argc argv:(char **)argv { } if (sdkRoot == nil) { - sdkRoot = [DTiPhoneSimulatorSystemRoot defaultRoot]; + Class systemRootClass = [self FindClassByName:@"DTiPhoneSimulatorSystemRoot"]; + sdkRoot = [systemRootClass defaultRoot]; } if (xctest) { NSString *appName = [appPath lastPathComponent]; diff --git a/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h b/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h deleted file mode 100644 index 8c63351..0000000 --- a/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h +++ /dev/null @@ -1,124 +0,0 @@ -#import - -/* - * File: /Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/iPhoneSimulatorRemoteClient.framework/Versions/A/iPhoneSimulatorRemoteClient - * Arch: Intel 80x86 (i386) - * Current version: 12.0.0, Compatibility version: 1.0.0 - */ - -@class DTiPhoneSimulatorSession; - -@protocol DTiPhoneSimulatorSessionDelegate - -- (void) session: (DTiPhoneSimulatorSession *) session didEndWithError: (NSError *) error; -- (void) session: (DTiPhoneSimulatorSession *) session didStart: (BOOL) started withError: (NSError *) error; - -@end - -@interface DTiPhoneSimulatorApplicationSpecifier : NSObject -{ - NSString *_appPath; - NSString *_bundleID; -} - -+ (id) specifierWithApplicationPath: (NSString *) appPath; -+ (id) specifierWithApplicationBundleIdentifier: (NSString *) bundleID; -- (NSString *) bundleID; -- (void) setBundleID: (NSString *) bundleId; -- (NSString *) appPath; -- (void) setAppPath: (NSString *) appPath; - -@end - -@interface DTiPhoneSimulatorSystemRoot : NSObject -{ - NSString *sdkRootPath; - NSString *sdkVersion; - NSString *sdkDisplayName; -} - -+ (id) defaultRoot; - -+ (id)rootWithSDKPath:(id)fp8; -+ (id)rootWithSDKVersion:(id)fp8; -+ (NSArray *) knownRoots; -- (id)initWithSDKPath:(id)fp8; -- (id)sdkDisplayName; -- (void)setSdkDisplayName:(id)fp8; -- (id)sdkVersion; -- (void)setSdkVersion:(id)fp8; -- (id)sdkRootPath; -- (void)setSdkRootPath:(id)fp8; - -@end - - - -@interface DTiPhoneSimulatorSessionConfig : NSObject -{ - NSString *_localizedClientName; - DTiPhoneSimulatorSystemRoot *_simulatedSystemRoot; - DTiPhoneSimulatorApplicationSpecifier *_applicationToSimulateOnStart; - NSArray *_simulatedApplicationLaunchArgs; - NSDictionary *_simulatedApplicationLaunchEnvironment; - BOOL _simulatedApplicationShouldWaitForDebugger; - NSString *_simulatedApplicationStdOutPath; - NSString *_simulatedApplicationStdErrPath; -} - -- (id)simulatedApplicationStdErrPath; -- (void)setSimulatedApplicationStdErrPath:(id)fp8; -- (id)simulatedApplicationStdOutPath; -- (void)setSimulatedApplicationStdOutPath:(id)fp8; -- (id)simulatedApplicationLaunchEnvironment; -- (void)setSimulatedApplicationLaunchEnvironment:(id)fp8; -- (id)simulatedApplicationLaunchArgs; -- (void)setSimulatedApplicationLaunchArgs:(id)fp8; - -- (DTiPhoneSimulatorApplicationSpecifier *) applicationToSimulateOnStart; -- (void) setApplicationToSimulateOnStart: (DTiPhoneSimulatorApplicationSpecifier *) appSpec; -- (DTiPhoneSimulatorSystemRoot *) simulatedSystemRoot; -- (void) setSimulatedSystemRoot: (DTiPhoneSimulatorSystemRoot *) simulatedSystemRoot; - - -- (BOOL) simulatedApplicationShouldWaitForDebugger; -- (void) setSimulatedApplicationShouldWaitForDebugger: (BOOL) waitForDebugger; - -- (id)localizedClientName; -- (void)setLocalizedClientName:(id)fp8; - -// Added in 3.2 to support iPad/iPhone device families -- (void)setSimulatedDeviceFamily:(NSNumber*)family; - -@end - - -@interface DTiPhoneSimulatorSession : NSObject { - NSString *_uuid; - id _delegate; - NSNumber *_simulatedApplicationPID; - int _sessionLifecycleProgress; - NSTimer *_timeoutTimer; - DTiPhoneSimulatorSessionConfig *_sessionConfig; - struct ProcessSerialNumber _simulatorPSN; -} - -- (BOOL) requestStartWithConfig: (DTiPhoneSimulatorSessionConfig *) config timeout: (NSTimeInterval) timeout error: (NSError **) outError; -- (void) requestEndWithTimeout: (NSTimeInterval) timeout; - -- (id)sessionConfig; -- (void)setSessionConfig:(id)fp8; -- (id)timeoutTimer; -- (void)setTimeoutTimer:(id)fp8; -- (int)sessionLifecycleProgress; -- (void)setSessionLifecycleProgress:(int)fp8; -- (id)simulatedApplicationPID; -- (void)setSimulatedApplicationPID:(id)fp8; - -- (id) delegate; -- (void) setDelegate: (id) delegate; - -- (id)uuid; -- (void)setUuid:(id)fp8; - -@end diff --git a/ios-sim.xcconfig b/ios-sim.xcconfig deleted file mode 100644 index 58074d2..0000000 --- a/ios-sim.xcconfig +++ /dev/null @@ -1,11 +0,0 @@ -DEVELOPER_PRIVATE_FRAMEWORK_DIR = "$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks" - -OTHER_LDFLAGS = -framework AppKit "-F$(DEVELOPER_PRIVATE_FRAMEWORK_DIR)" -framework iPhoneSimulatorRemoteClient "-Wl,-rpath" "-Wl,$(DEVELOPER_PRIVATE_FRAMEWORK_DIR)" "-Wl,-rpath" "-Wl,$(DEVELOPER_DIR)/../OtherFrameworks" - -EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES = $(OTHER_LDFLAGS) - -INFOPLIST_PREPROCESSOR_DEFINITIONS = $(OTHER_LDFLAGS) - -FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_PRIVATE_FRAMEWORK_DIR)" - -HEADER_SEARCH_PATHS = . diff --git a/ios-sim.xcodeproj/project.pbxproj b/ios-sim.xcodeproj/project.pbxproj index 0bc27d0..61076c1 100644 --- a/ios-sim.xcodeproj/project.pbxproj +++ b/ios-sim.xcodeproj/project.pbxproj @@ -34,7 +34,6 @@ 2481364A115A750000E3A9BA /* nsprintf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = nsprintf.h; path = Source/nsprintf.h; sourceTree = ""; }; 2481364B115A750000E3A9BA /* nsprintf.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = nsprintf.m; path = Source/nsprintf.m; sourceTree = ""; }; 32A70AAB03705E1F00C91783 /* ios-sim_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ios-sim_Prefix.pch"; sourceTree = ""; }; - 510E9B1215246BB10010A2B7 /* ios-sim.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "ios-sim.xcconfig"; sourceTree = ""; }; 51448B3212BCF637001F99BD /* NSString+expandPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+expandPath.h"; path = "Source/NSString+expandPath.h"; sourceTree = ""; }; 51448B3312BCF637001F99BD /* NSString+expandPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+expandPath.m"; path = "Source/NSString+expandPath.m"; sourceTree = ""; }; 51448B3512BD0328001F99BD /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = version.h; path = Source/version.h; sourceTree = ""; }; @@ -56,7 +55,6 @@ 08FB7794FE84155DC02AAC07 /* iphonesim */ = { isa = PBXGroup; children = ( - 510E9B1215246BB10010A2B7 /* ios-sim.xcconfig */, 08FB7795FE84155DC02AAC07 /* Source */, 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */, 1AB674ADFE9D54B511CA2CBB /* Products */, @@ -161,7 +159,6 @@ /* Begin XCBuildConfiguration section */ 1DEB927508733DD40010E9CD /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 510E9B1215246BB10010A2B7 /* ios-sim.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; @@ -179,7 +176,6 @@ }; 1DEB927608733DD40010E9CD /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 510E9B1215246BB10010A2B7 /* ios-sim.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -201,6 +197,7 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = .; ONLY_ACTIVE_ARCH = NO; SDKROOT = macosx; VALID_ARCHS = "i386 x86_64"; @@ -214,6 +211,7 @@ GCC_C_LANGUAGE_STANDARD = gnu99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = .; ONLY_ACTIVE_ARCH = NO; SDKROOT = macosx; VALID_ARCHS = "i386 x86_64"; diff --git a/ios-sim.xcodeproj/xcshareddata/xcschemes/ios-sim.xcscheme b/ios-sim.xcodeproj/xcshareddata/xcschemes/ios-sim.xcscheme index 101a481..42506f9 100644 --- a/ios-sim.xcodeproj/xcshareddata/xcschemes/ios-sim.xcscheme +++ b/ios-sim.xcodeproj/xcshareddata/xcschemes/ios-sim.xcscheme @@ -1,6 +1,6 @@ Date: Mon, 10 Mar 2014 21:56:33 -0700 Subject: [PATCH 2/3] Fixed ""Failed to find class DTiPhoneSimulatorSystemRoot at runtime" error --- Source/iPhoneSimulator.m | 9 +++++++++ Source/version.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/iPhoneSimulator.m b/Source/iPhoneSimulator.m index 62f4d79..a5e9229 100644 --- a/Source/iPhoneSimulator.m +++ b/Source/iPhoneSimulator.m @@ -402,7 +402,14 @@ - (void)runWithArgc:(int)argc argv:(char **)argv { alreadyPrintedData = NO; startOnly = strcmp(argv[1], "start") == 0; + NSString* developerDir = FindDeveloperDir(); + if (!developerDir) { + nsprintf(@"Unable to find developer directory."); + exit(EXIT_FAILURE); + } + if (strcmp(argv[1], "showsdks") == 0) { + [self LoadSimulatorFramework:developerDir]; exit([self showSDKs]); } else if (strcmp(argv[1], "launch") == 0 || startOnly) { if (strcmp(argv[1], "launch") == 0 && argc < 3) { @@ -453,6 +460,7 @@ - (void)runWithArgc:(int)argc argv:(char **)argv { } else if (strcmp(argv[i], "--sdk") == 0) { i++; + [self LoadSimulatorFramework:developerDir]; NSString* ver = [NSString stringWithCString:argv[i] encoding:NSUTF8StringEncoding]; Class systemRootClass = [self FindClassByName:@"DTiPhoneSimulatorSystemRoot"]; NSArray *roots = [systemRootClass knownRoots]; @@ -518,6 +526,7 @@ - (void)runWithArgc:(int)argc argv:(char **)argv { } if (sdkRoot == nil) { + [self LoadSimulatorFramework:developerDir]; Class systemRootClass = [self FindClassByName:@"DTiPhoneSimulatorSystemRoot"]; sdkRoot = [systemRootClass defaultRoot]; } diff --git a/Source/version.h b/Source/version.h index cc32a10..d22dd94 100644 --- a/Source/version.h +++ b/Source/version.h @@ -1 +1 @@ -#define IOS_SIM_VERSION "1.8.2" +#define IOS_SIM_VERSION "1.9.0" From b9a7e694a3d3f8db27c49af5609508a5fc9fcb56 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Mon, 10 Mar 2014 22:23:01 -0700 Subject: [PATCH 3/3] Fixed ""The application that opened iOS Simulator failed to send all of the required information" error --- Source/iPhoneSimulator.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/iPhoneSimulator.m b/Source/iPhoneSimulator.m index a5e9229..f3e9160 100644 --- a/Source/iPhoneSimulator.m +++ b/Source/iPhoneSimulator.m @@ -342,7 +342,8 @@ - (int)launchApp:(NSString *)path withFamily:(NSString *)family } } - [self changeDeviceType:family retina:retinaDevice isTallDevice:tallDevice]; + NSString* devicePropertyValue = [self changeDeviceType:family retina:retinaDevice isTallDevice:tallDevice]; + [config setSimulatedDeviceInfoName:devicePropertyValue]; /* Start the session */ session = [[[[self FindClassByName:@"DTiPhoneSimulatorSession"] alloc] init] autorelease]; @@ -359,7 +360,7 @@ - (int)launchApp:(NSString *)path withFamily:(NSString *)family return EXIT_SUCCESS; } -- (void) changeDeviceType:(NSString *)family retina:(BOOL)retina isTallDevice:(BOOL)isTallDevice { +- (NSString*) changeDeviceType:(NSString *)family retina:(BOOL)retina isTallDevice:(BOOL)isTallDevice { NSString *devicePropertyValue; if (retina) { if (verbose) { @@ -384,6 +385,8 @@ - (void) changeDeviceType:(NSString *)family retina:(BOOL)retina isTallDevice:(B } CFPreferencesSetAppValue((CFStringRef)deviceProperty, (CFPropertyListRef)devicePropertyValue, (CFStringRef)simulatorPrefrencesName); CFPreferencesAppSynchronize((CFStringRef)simulatorPrefrencesName); + + return devicePropertyValue; }