From 470f7973d297ff07d16a9f2a73706d868bb738e9 Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Fri, 14 Mar 2014 00:07:35 +0100 Subject: ios: simulator support for Xcode 5.1 update iossim to be based on version 1.9.0, so that we can support the new Xcode 5.1. Keep the old version around and use it with older Xcode. All the logic has been moved into iossim which does an exec of the older binary if needed (so that creator itself remains untouched) Task-number: QTCREATORBUG-11714 Change-Id: I4ad9f922f22367c8371b3be68eae5b6dfdf4df5c Reviewed-by: Fawzi Mohamed --- src/tools/3rdparty/3rdparty.pro | 4 +- .../dvtiphonesimulatorremoteclient.h | 290 +++++++++++ src/tools/3rdparty/iossim/iossim.pro | 21 +- src/tools/3rdparty/iossim/iphonesimulator.h | 8 +- src/tools/3rdparty/iossim/iphonesimulator.mm | 310 +++++++---- .../iphonesimulatorremoteclient.h | 126 ----- src/tools/3rdparty/iossim/main.mm | 58 +-- src/tools/3rdparty/iossim/nsprintf.mm | 4 +- src/tools/3rdparty/iossim/nsstringexpandpath.mm | 2 +- src/tools/3rdparty/iossim/version.h | 2 +- src/tools/3rdparty/iossim_1_8_2/IOSSIM_LICENSE | 31 ++ src/tools/3rdparty/iossim_1_8_2/Info.plist | 16 + src/tools/3rdparty/iossim_1_8_2/iossim.qbs | 30 ++ src/tools/3rdparty/iossim_1_8_2/iossim_1_8_2.pro | 55 ++ src/tools/3rdparty/iossim_1_8_2/iphonesimulator.h | 41 ++ src/tools/3rdparty/iossim_1_8_2/iphonesimulator.mm | 566 +++++++++++++++++++++ .../iphonesimulatorremoteclient.h | 126 +++++ src/tools/3rdparty/iossim_1_8_2/main.mm | 77 +++ src/tools/3rdparty/iossim_1_8_2/nsprintf.h | 6 + src/tools/3rdparty/iossim_1_8_2/nsprintf.mm | 44 ++ .../3rdparty/iossim_1_8_2/nsstringexpandpath.h | 11 + .../3rdparty/iossim_1_8_2/nsstringexpandpath.mm | 18 + src/tools/3rdparty/iossim_1_8_2/version.h | 1 + 23 files changed, 1542 insertions(+), 305 deletions(-) create mode 100644 src/tools/3rdparty/iossim/dvtiphonesimulatorremoteclient/dvtiphonesimulatorremoteclient.h delete mode 100644 src/tools/3rdparty/iossim/iphonesimulatorremoteclient/iphonesimulatorremoteclient.h create mode 100644 src/tools/3rdparty/iossim_1_8_2/IOSSIM_LICENSE create mode 100644 src/tools/3rdparty/iossim_1_8_2/Info.plist create mode 100644 src/tools/3rdparty/iossim_1_8_2/iossim.qbs create mode 100644 src/tools/3rdparty/iossim_1_8_2/iossim_1_8_2.pro create mode 100644 src/tools/3rdparty/iossim_1_8_2/iphonesimulator.h create mode 100644 src/tools/3rdparty/iossim_1_8_2/iphonesimulator.mm create mode 100644 src/tools/3rdparty/iossim_1_8_2/iphonesimulatorremoteclient/iphonesimulatorremoteclient.h create mode 100644 src/tools/3rdparty/iossim_1_8_2/main.mm create mode 100644 src/tools/3rdparty/iossim_1_8_2/nsprintf.h create mode 100644 src/tools/3rdparty/iossim_1_8_2/nsprintf.mm create mode 100644 src/tools/3rdparty/iossim_1_8_2/nsstringexpandpath.h create mode 100644 src/tools/3rdparty/iossim_1_8_2/nsstringexpandpath.mm create mode 100644 src/tools/3rdparty/iossim_1_8_2/version.h diff --git a/src/tools/3rdparty/3rdparty.pro b/src/tools/3rdparty/3rdparty.pro index 9b9062f2d9..c0c053bf4c 100644 --- a/src/tools/3rdparty/3rdparty.pro +++ b/src/tools/3rdparty/3rdparty.pro @@ -1,5 +1,7 @@ TEMPLATE = subdirs mac { - SUBDIRS += iossim + SUBDIRS += \ + iossim \ + iossim_1_8_2 } diff --git a/src/tools/3rdparty/iossim/dvtiphonesimulatorremoteclient/dvtiphonesimulatorremoteclient.h b/src/tools/3rdparty/iossim/dvtiphonesimulatorremoteclient/dvtiphonesimulatorremoteclient.h new file mode 100644 index 0000000000..70cc4ac436 --- /dev/null +++ b/src/tools/3rdparty/iossim/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/src/tools/3rdparty/iossim/iossim.pro b/src/tools/3rdparty/iossim/iossim.pro index c880da3f4e..25f185cb0f 100644 --- a/src/tools/3rdparty/iossim/iossim.pro +++ b/src/tools/3rdparty/iossim/iossim.pro @@ -1,7 +1,8 @@ CONFIG += console -QT += core -QT += gui +QT -= core +QT -= gui +QT -= test CONFIG -= app_bundle @@ -25,14 +26,11 @@ iPhoneSimulatorRemoteClientDirectLinking { LIBS += \ -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks \ -F/Applications/Xcode.app/Contents/OtherFrameworks - - QMAKE_LFLAGS += -Wl,-rpath,/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks \ - -Wl,-rpath,/Applications/Xcode.app/Contents/OtherFrameworks \ LIBS += \ - -framework iPhoneSimulatorRemoteClient - QMAKE_RPATHDIR += /Applications/Xcode5-DP5.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks \ - /Applications/Xcode.app/Contents/OtherFrameworks - /System/Library/PrivateFrameworks \ + -framework DTViPhoneSimulatorRemoteClient + QMAKE_RPATHDIR += /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks \ + /Applications/Xcode.app/Contents/OtherFrameworks \ + /System/Library/PrivateFrameworks } TEMPLATE = app @@ -52,6 +50,7 @@ HEADERS += \ nsprintf.h \ nsstringexpandpath.h \ version.h \ - iphonesimulatorremoteclient/iphonesimulatorremoteclient.h + dvtiphonesimulatorremoteclient/dvtiphonesimulatorremoteclient.h -OTHER_FILES = LICENSE +OTHER_FILES = IOSSIM_LICENSE \ + Info.plist diff --git a/src/tools/3rdparty/iossim/iphonesimulator.h b/src/tools/3rdparty/iossim/iphonesimulator.h index 0770c50ee3..3049f318d2 100644 --- a/src/tools/3rdparty/iossim/iphonesimulator.h +++ b/src/tools/3rdparty/iossim/iphonesimulator.h @@ -6,7 +6,7 @@ */ #import -#import "iphonesimulatorremoteclient/iphonesimulatorremoteclient.h" +#import #import "version.h" @interface iPhoneSimulator : NSObject { @@ -14,8 +14,7 @@ DTiPhoneSimulatorSystemRoot *sdkRoot; NSFileHandle *stdoutFileHandle; NSFileHandle *stderrFileHandle; - DTiPhoneSimulatorSession *session; - NSTimer *pidCheckingTimer; + DTiPhoneSimulatorSession *mySession; BOOL startOnly; BOOL exitOnStartup; BOOL shouldWaitDebugger; @@ -34,8 +33,7 @@ - (void)createStdioFIFO:(NSFileHandle **)fileHandle ofType:(NSString *)type atPath:(NSString **)path; - (void)removeStdioFIFO:(NSFileHandle *)fileHandle atPath:(NSString *)path; - (void)stop; -- (void)checkPid:(NSTimer *)timer; - (void)doExit:(int)errorCode; -- (void)changeDeviceType:(NSString *)family retina:(BOOL)retina isTallDevice:(BOOL)isTallDevice; +- (NSString*)changeDeviceType:(NSString *)family retina:(BOOL)retina isTallDevice:(BOOL)isTallDevice; @end diff --git a/src/tools/3rdparty/iossim/iphonesimulator.mm b/src/tools/3rdparty/iossim/iphonesimulator.mm index b06b54276d..d4ba36224d 100644 --- a/src/tools/3rdparty/iossim/iphonesimulator.mm +++ b/src/tools/3rdparty/iossim/iphonesimulator.mm @@ -10,8 +10,9 @@ #import "nsprintf.h" #import #import -#import -#import +#import +#import +@class DTiPhoneSimulatorSystemRoot; NSString *simulatorPrefrencesName = @"com.apple.iphonesimulator"; NSString *deviceProperty = @"SimulateDevice"; @@ -21,6 +22,18 @@ NSString *deviceIphone = @"iPhone"; 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"; + +static const char *gDevDir = 0; + +@interface DVTPlatform : NSObject ++ (BOOL)loadAllPlatformsReturningError:(id*)arg1; +@end + /** * A simple iPhoneSimulatorRemoteClient framework. */ @@ -28,14 +41,12 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; - (id)init { self = [super init]; - session = nil; - pidCheckingTimer = nil; + mySession = nil; return self; } - (void)dealloc { - [session release]; - [pidCheckingTimer release]; + [mySession release]; [super dealloc]; } @@ -47,8 +58,88 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; exit(errorCode); } +// 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); + [self doExit: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: "); + [self doExit: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() { + if (gDevDir) + return [NSString stringWithCString:gDevDir encoding:NSUTF8StringEncoding]; + // 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(stdout, "Usage: iossim [--args ...]\n"); + fprintf(stdout, "Usage: ios-sim [--args ...]\n"); fprintf(stdout, "\n"); fprintf(stdout, "Commands:\n"); fprintf(stdout, " showsdks List the available iOS SDK versions\n"); @@ -80,61 +171,60 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; - (int) showSDKs { - NSUInteger i; - id tClass = objc_getClass("DTiPhoneSimulatorSystemRoot"); - if (tClass == nil) { - nsprintf(@"DTiPhoneSimulatorSystemRoot class is nil."); - return EXIT_FAILURE; - } - NSArray *roots = [tClass knownRoots]; + Class systemRootClass = [self FindClassByName:@"DTiPhoneSimulatorSystemRoot"]; + + NSArray *roots = [systemRootClass knownRoots]; nsprintf(@""); - for (i = 0; i < [roots count]; ++i) { + for (NSUInteger i = 0; i < [roots count]; ++i) { DTiPhoneSimulatorSystemRoot *root = [roots objectAtIndex:i]; - nsprintf(@"sdk%d_name%@", i, [root sdkDisplayName]); - nsprintf(@"sdk%d_version%@", i, [root sdkVersion]); - nsprintf(@"sdk%d_sysroot%@", i, [root sdkRootPath]); + nsprintf(@"sdk%d_name%@", i, [root sdkDisplayName]); + nsprintf(@"sdk%d_version%@", i, [root sdkVersion]); + nsprintf(@"sdk%d_sysroot%@", i, [root sdkRootPath]); } nsprintf(@""); + return EXIT_SUCCESS; } -- (void)session:(DTiPhoneSimulatorSession *)mySession didEndWithError:(NSError *)error { +- (void)session:(DTiPhoneSimulatorSession *)session didEndWithError:(NSError *)error { if (verbose) { nsprintf(@"Session did end with error %@", error); } if (stderrFileHandle != nil) { - NSString *stderrPath = [[mySession sessionConfig] simulatedApplicationStdErrPath]; + NSString *stderrPath = [[session sessionConfig] simulatedApplicationStdErrPath]; [self removeStdioFIFO:stderrFileHandle atPath:stderrPath]; } if (stdoutFileHandle != nil) { - NSString *stdoutPath = [[mySession sessionConfig] simulatedApplicationStdOutPath]; + NSString *stdoutPath = [[session sessionConfig] simulatedApplicationStdOutPath]; [self removeStdioFIFO:stdoutFileHandle atPath:stdoutPath]; } - if (error != nil) + if (error != nil) { [self doExit:EXIT_FAILURE]; - else - [self doExit:EXIT_SUCCESS]; + } + + [self doExit:EXIT_SUCCESS]; } -- (void)session:(DTiPhoneSimulatorSession *)mySession didStart:(BOOL)started withError:(NSError *)error { - if (startOnly && mySession) { - [NSTask launchedTaskWithLaunchPath:@"/usr/bin/osascript" - arguments:[NSArray arrayWithObjects:@"-e", @"tell application \"iPhone Simulator\" to activate", nil]]; - nsprintf(@"Simulator started (no session)"); - [self doExit:EXIT_SUCCESS]; - return; +- (void)session:(DTiPhoneSimulatorSession *)session didStart:(BOOL)started withError:(NSError *)error { + if (startOnly && session) { + [NSTask launchedTaskWithLaunchPath:@"/usr/bin/osascript" + arguments:[NSArray arrayWithObjects:@"-e", @"tell application \"iPhone Simulator\" to activate", nil]]; + nsprintf(@"Simulator started (no session)"); + [self doExit:EXIT_SUCCESS]; + return; } if (started) { [NSTask launchedTaskWithLaunchPath:@"/usr/bin/osascript" arguments:[NSArray arrayWithObjects:@"-e", @"tell application \"iPhone Simulator\" to activate", nil]]; + int pid = [session simulatedApplicationPID]; if (shouldStartDebugger) { - char*args[4] = { NULL, NULL, (char*)[[[mySession simulatedApplicationPID] description] UTF8String], NULL }; + char*args[4] = { NULL, NULL, (char*)[[[NSNumber numberWithInt:pid] description] UTF8String], NULL }; if (useGDB) { args[0] = strdup("gdb"); args[1] = strdup("program"); @@ -156,35 +246,23 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; if (verbose) { nsprintf(@"Session started"); } - nsprintf(@"%@", [session simulatedApplicationPID]); + nsprintf(@"%d", pid); fflush(stdout); if (exitOnStartup) { - [self doExit:EXIT_SUCCESS]; - return; + [self doExit:EXIT_SUCCESS]; + return; } - pidCheckingTimer = [[NSTimer scheduledTimerWithTimeInterval:5.0 target:self - selector:@selector(checkPid:) userInfo:nil repeats: TRUE] retain]; } else { - nsprintf(@"Session could not be started: %@", error); - [self doExit:EXIT_FAILURE]; + nsprintf(@"Session could not be started: %@", error); + [self doExit:EXIT_FAILURE]; } } - (void)stop { - if (session) - [session requestEndWithTimeout: 0.1]; + if (mySession) + [mySession requestEndWithTimeout: 0.1]; } -- (void)checkPid:(NSTimer *)timer { - (void)timer; - if (session && [[session simulatedApplicationPID]intValue] > 0) { - if (kill((pid_t)[[session simulatedApplicationPID]intValue], 0) == -1) { - nsprintf(@"app stopped"); - [self doExit:EXIT_SUCCESS]; - return; - } - } -} - (void)stdioDataIsAvailable:(NSNotification *)notification { [[notification object] readInBackgroundAndNotify]; NSData *data = [[notification userInfo] valueForKey:NSFileHandleNotificationDataItem]; @@ -208,7 +286,7 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; - (void)createStdioFIFO:(NSFileHandle **)fileHandle ofType:(NSString *)type atPath:(NSString **)path { *path = [NSString stringWithFormat:@"%@/ios-sim-%@-pipe-%d", NSTemporaryDirectory(), type, (int)time(NULL)]; if (mkfifo([*path UTF8String], S_IRUSR | S_IWUSR) == -1) { - nsprintf(@"Unable to create %@ named pipe `%@'", type, *path); + nsprintf(@"Unable to create %@ named pipe `%@'", type, *path); [self doExit:EXIT_FAILURE]; } else { if (verbose) { @@ -246,33 +324,27 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; args:(NSArray *)args { DTiPhoneSimulatorApplicationSpecifier *appSpec; DTiPhoneSimulatorSessionConfig *config; - NSError *error = 0; - id tClass; + DTiPhoneSimulatorSession *session; + NSError *error; NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; if (!startOnly && ![fileManager fileExistsAtPath:path]) { - nsprintf(@"Application path %@ doesn't exist!", path); - return EXIT_FAILURE; + nsprintf(@"Application path %@ doesn't exist!", path); + return EXIT_FAILURE; } /* Create the app specifier */ - tClass = objc_getClass("DTiPhoneSimulatorApplicationSpecifier"); - if (tClass == nil) { - nsprintf(@"DTiPhoneSimulatorApplicationSpecifier class is nil."); - return EXIT_FAILURE; - } - appSpec = startOnly ? nil : [tClass specifierWithApplicationPath:path]; + appSpec = startOnly ? nil : [[self FindClassByName:@"DTiPhoneSimulatorApplicationSpecifier"] specifierWithApplicationPath:path]; if (verbose) { - nsprintf(@"App Spec: %@", appSpec); - nsprintf(@"SDK Root: %@", sdkRoot); + nsprintf(@"App Spec: %@", appSpec); + nsprintf(@"SDK Root: %@", sdkRoot); for (id key in environment) { nsprintf(@"Env: %@ = %@", key, [environment objectForKey:key]); } } - NSString *sdkVersion = [sdkRoot sdkVersion]; NSString *appSupportDir = [NSString stringWithFormat:@"%@/Library/Application Support/iPhone Simulator/%@", NSHomeDirectory(), sdkVersion]; @@ -288,12 +360,7 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; environment = mutableEnv; /* Set up the session configuration */ - tClass = objc_getClass("DTiPhoneSimulatorSessionConfig"); - if (tClass == nil) { - nsprintf(@"DTiPhoneSimulatorApplicationSpecifier class is nil."); - return EXIT_FAILURE; - } - config = [[[tClass alloc] init] autorelease]; + config = [[[[self FindClassByName:@"DTiPhoneSimulatorSessionConfig"] alloc] init] autorelease]; [config setApplicationToSimulateOnStart:appSpec]; [config setSimulatedSystemRoot:sdkRoot]; [config setSimulatedApplicationShouldWaitForDebugger:shouldWaitDebugger]; @@ -333,16 +400,13 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; [config setSimulatedDeviceFamily:[NSNumber numberWithInt:1]]; } } - - [self changeDeviceType:family retina:retinaDevice isTallDevice:tallDevice]; + + NSString* devicePropertyValue = [self changeDeviceType:family retina:retinaDevice isTallDevice:tallDevice]; + [config setSimulatedDeviceInfoName:devicePropertyValue]; /* Start the session */ - tClass = objc_getClass("DTiPhoneSimulatorSession"); - if (tClass == nil) { - nsprintf(@"DTiPhoneSimulatorSession class is nil."); - return EXIT_FAILURE; - } - session = [[tClass alloc] init]; + session = [[[[self FindClassByName:@"DTiPhoneSimulatorSession"] alloc] init] autorelease]; + mySession = session; [session setDelegate:self]; if (uuid != nil){ [session setUuid:uuid]; @@ -356,7 +420,7 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; 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) { @@ -381,6 +445,8 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; } CFPreferencesSetAppValue((CFStringRef)deviceProperty, (CFPropertyListRef)devicePropertyValue, (CFStringRef)simulatorPrefrencesName); CFPreferencesAppSynchronize((CFStringRef)simulatorPrefrencesName); + + return devicePropertyValue; } @@ -398,17 +464,41 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; exitOnStartup = NO; alreadyPrintedData = NO; startOnly = strcmp(argv[1], "start") == 0; - nsprintf(@""); + nsprintf(@""); + for (int i = 0; i < argc; ++i) { + if (strcmp(argv[i], "--developer-path") == 0) { + ++i; + if (i < argc) + gDevDir = argv[i]; + } + } + NSString* developerDir = FindDeveloperDir(); + if (!developerDir) { + nsprintf(@"Unable to find developer directory."); + exit(EXIT_FAILURE); + } + NSString* dvtFoundationPath = [developerDir stringByAppendingPathComponent:kDVTFoundationRelativePath]; + if (![[NSFileManager defaultManager] fileExistsAtPath:dvtFoundationPath]) { + // execute old version + char *argNew = new char[strlen(argv[0] + 7)]; + strcpy(argNew, argv[0]); + strcat(argNew, "_1_8_2"); + char **argvNew = new char *[argc + 1]; + argvNew[0] = argNew; + for (int iarg = 1; iarg < argc; ++iarg) + argvNew[iarg] = argv[iarg]; + argvNew[argc] = 0; + execv(argNew, argvNew); + } if (strcmp(argv[1], "showsdks") == 0) { - [self doExit:[self showSDKs]]; - return; + [self LoadSimulatorFramework:developerDir]; + exit([self showSDKs]); } else if (strcmp(argv[1], "launch") == 0 || startOnly) { if (strcmp(argv[1], "launch") == 0 && argc < 3) { nsprintf(@"Missing application path argument"); [self printUsage]; - [self doExit:EXIT_FAILURE]; - return; + exit(EXIT_FAILURE); } NSString *appPath = nil; @@ -425,6 +515,7 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; NSString *uuid = nil; NSString *stdoutPath = nil; NSString *stderrPath = nil; + NSString *xctest = nil; NSTimeInterval timeout = 30; NSMutableDictionary *environment = [NSMutableDictionary dictionary]; @@ -452,20 +543,15 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; } else if (strcmp(argv[i], "--timeout") == 0) { if (i + 1 < argc) { timeout = [[NSString stringWithUTF8String:argv[++i]] doubleValue]; - NSLog(@"Timeout: %f second(s)", timeout); + NSLog(@"Timeout: %f second(s)", timeout); } } else if (strcmp(argv[i], "--sdk") == 0) { i++; + [self LoadSimulatorFramework:developerDir]; NSString* ver = [NSString stringWithCString:argv[i] encoding:NSUTF8StringEncoding]; - id tClass = objc_getClass("DTiPhoneSimulatorSystemRoot"); - NSArray *roots; - if (tClass == nil) { - nsprintf(@"DTiPhoneSimulatorSystemRoot class is nil."); - [self doExit:EXIT_FAILURE]; - return; - } - roots = [tClass knownRoots]; + Class systemRootClass = [self FindClassByName:@"DTiPhoneSimulatorSystemRoot"]; + NSArray *roots = [systemRootClass knownRoots]; for (DTiPhoneSimulatorSystemRoot *root in roots) { NSString *v = [root sdkVersion]; if ([v isEqualToString:ver]) { @@ -491,7 +577,7 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; } else if (strcmp(argv[i], "--env") == 0) { i++; NSString *envFilePath = [[NSString stringWithUTF8String:argv[i]] expandPath]; - environment = [NSDictionary dictionaryWithContentsOfFile:envFilePath]; + [environment setValuesForKeysWithDictionary:[NSDictionary dictionaryWithContentsOfFile:envFilePath]]; if (!environment) { fprintf(stdout, "Could not read environment from file: %s\n", argv[i]); [self printUsage]; @@ -502,9 +588,13 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; stdoutPath = [[NSString stringWithUTF8String:argv[i]] expandPath]; NSLog(@"stdoutPath: %@", stdoutPath); } else if (strcmp(argv[i], "--stderr") == 0) { - i++; - stderrPath = [[NSString stringWithUTF8String:argv[i]] expandPath]; - NSLog(@"stderrPath: %@", stderrPath); + i++; + stderrPath = [[NSString stringWithUTF8String:argv[i]] expandPath]; + NSLog(@"stderrPath: %@", stderrPath); + } else if (strcmp(argv[i], "--xctest") == 0) { + i++; + xctest = [[NSString stringWithUTF8String:argv[i]] expandPath]; + NSLog(@"xctest: %@", xctest); } else if (strcmp(argv[i], "--retina") == 0) { retinaDevice = YES; } else if (strcmp(argv[i], "--tall") == 0) { @@ -513,7 +603,7 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; i++; break; } else { - printf("unrecognized argument:%s\n", argv[i]); + fprintf(stdout, "unrecognized argument:%s\n", argv[i]); [self printUsage]; [self doExit:EXIT_FAILURE]; return; @@ -525,13 +615,19 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; } if (sdkRoot == nil) { - id tClass = objc_getClass("DTiPhoneSimulatorSystemRoot"); - if (tClass == nil) { - nsprintf(@"DTiPhoneSimulatorSystemRoot class is nil."); - [self doExit:EXIT_FAILURE]; - return; - } - sdkRoot = [tClass defaultRoot]; + [self LoadSimulatorFramework:developerDir]; + Class systemRootClass = [self FindClassByName:@"DTiPhoneSimulatorSystemRoot"]; + sdkRoot = [systemRootClass defaultRoot]; + } + if (xctest) { + NSString *appName = [appPath lastPathComponent]; + NSString *executableName = [appName stringByDeletingPathExtension]; + NSString *injectionPath = @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection"; + [environment setValuesForKeysWithDictionary:[NSDictionary dictionaryWithObjectsAndKeys: + injectionPath,@"DYLD_INSERT_LIBRARIES", + xctest, @"XCInjectBundle", + [appPath stringByAppendingFormat:@"/%@", executableName],@"XCInjectBundleInto", + nil]]; } /* Don't exit, adds to runloop */ @@ -556,7 +652,7 @@ NSString *deviceIpadRetina = @"iPad (Retina)"; printf("%s\n", IOS_SIM_VERSION); [self doExit:EXIT_SUCCESS]; } else { - fprintf(stdout, "Unknown command\n"); + fprintf(stderr, "Unknown command\n"); [self printUsage]; [self doExit:EXIT_FAILURE]; } diff --git a/src/tools/3rdparty/iossim/iphonesimulatorremoteclient/iphonesimulatorremoteclient.h b/src/tools/3rdparty/iossim/iphonesimulatorremoteclient/iphonesimulatorremoteclient.h deleted file mode 100644 index abf69c8067..0000000000 --- a/src/tools/3rdparty/iossim/iphonesimulatorremoteclient/iphonesimulatorremoteclient.h +++ /dev/null @@ -1,126 +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 - * - * See the IOSSIM_LICENSE file in the parent directory for the license on the source code in this file. - */ - -@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/src/tools/3rdparty/iossim/main.mm b/src/tools/3rdparty/iossim/main.mm index 29b67c5c33..7e88c5e485 100644 --- a/src/tools/3rdparty/iossim/main.mm +++ b/src/tools/3rdparty/iossim/main.mm @@ -5,69 +5,25 @@ * See the IOSSIM_LICENSE file in this directory for the license on the source code in this file. */ /* derived from https://github.com/phonegap/ios-sim */ + #import -#import "iphonesimulator.h" -#include -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -#include -#else -#include -#endif -#include -#include +#import -/* to do: - * - try to stop inferior when killed (or communicate with creator to allow killing the inferior) - * - remove unneeded functionality and streamline a bit - */ +#import "iphonesimulator.h" /* * Runs the iPhoneSimulator backed by a main runloop. */ int main (int argc, char *argv[]) { -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - QApplication a(argc, argv); -#else - QGuiApplication a(argc, argv); -#endif - - - //NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - QString xcodePath = QLatin1String("/Applications/Xcode.app/Contents/Developer/"); - for (int i = 0; i + 1 < argc; ++i) { - if (strcmp(argv[i], "--developer-path") == 0) - xcodePath = QCoreApplication::arguments().at(i+1); - } - if (!xcodePath.endsWith(QLatin1Char('/'))) - xcodePath.append(QLatin1Char('/')); - - /* manual loading of the private deps */ - QStringList deps = QStringList() - << QLatin1String("/System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols") - << QLatin1String("/System/Library/PrivateFrameworks/CoreSymbolication.framework/CoreSymbolication") - << (xcodePath + QLatin1String("../OtherFrameworks/DevToolsFoundation.framework/DevToolsFoundation")); - foreach (const QString &libPath, deps) { - QLibrary *lib = new QLibrary(libPath); - //lib->setLoadHints(QLibrary::ExportExternalSymbolsHint); - if (!lib->load()) - printf("error loading %s", libPath.toUtf8().constData()); - } - QLibrary *libIPhoneSimulatorRemoteClient = new QLibrary(xcodePath - + QLatin1String("Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/iPhoneSimulatorRemoteClient.framework/iPhoneSimulatorRemoteClient")); - //libIPhoneSimulatorRemoteClient->setLoadHints(QLibrary::ResolveAllSymbolsHint|QLibrary::ExportExternalSymbolsHint); - if (!libIPhoneSimulatorRemoteClient->load()) - printf("error loading iPhoneSimulatorRemoteClient"); - + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; iPhoneSimulator *sim = [[iPhoneSimulator alloc] init]; - + /* Execute command line handler */ [sim runWithArgc: argc argv: argv]; /* Run the loop to handle added input sources, if any */ + [[NSRunLoop mainRunLoop] run]; - int res = a.exec(); - exit(res); - // [pool release]; + [pool release]; return 0; } diff --git a/src/tools/3rdparty/iossim/nsprintf.mm b/src/tools/3rdparty/iossim/nsprintf.mm index b7413f593c..95c12c785f 100644 --- a/src/tools/3rdparty/iossim/nsprintf.mm +++ b/src/tools/3rdparty/iossim/nsprintf.mm @@ -24,7 +24,7 @@ int nsfprintf (FILE *stream, NSString *format, ...) { va_start(ap, format); { retval = nsvfprintf(stream, format, ap); - } + } va_end(ap); return retval; @@ -37,7 +37,7 @@ int nsprintf (NSString *format, ...) { va_start(ap, format); { retval = nsvfprintf(stdout, format, ap); - } + } va_end(ap); return retval; diff --git a/src/tools/3rdparty/iossim/nsstringexpandpath.mm b/src/tools/3rdparty/iossim/nsstringexpandpath.mm index 53f43e3c12..b36481b504 100644 --- a/src/tools/3rdparty/iossim/nsstringexpandpath.mm +++ b/src/tools/3rdparty/iossim/nsstringexpandpath.mm @@ -1,5 +1,5 @@ /* - * See the IOSSIM_LICENSE file in this directory for the license on the source code in this file. + * See the LICENSE file for the license on the source code in this file. */ #import "nsstringexpandpath.h" diff --git a/src/tools/3rdparty/iossim/version.h b/src/tools/3rdparty/iossim/version.h index 9f8c0dfc91..d22dd94b8e 100644 --- a/src/tools/3rdparty/iossim/version.h +++ b/src/tools/3rdparty/iossim/version.h @@ -1 +1 @@ -#define IOS_SIM_VERSION "1.8.2m" +#define IOS_SIM_VERSION "1.9.0" diff --git a/src/tools/3rdparty/iossim_1_8_2/IOSSIM_LICENSE b/src/tools/3rdparty/iossim_1_8_2/IOSSIM_LICENSE new file mode 100644 index 0000000000..162622f1db --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/IOSSIM_LICENSE @@ -0,0 +1,31 @@ +Author: Landon Fuller +Copyright (c) 2008-2011 Plausible Labs Cooperative, Inc. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Modifications made by the following entities are licensed as above: +- Jeff Haynie, Appcelerator, Inc. +- https://github.com/hborders +- http://pivotallabs.com/users/scoward/blog +- Eloy Duran, Fingertips +- Fawzi Mohamed, digia diff --git a/src/tools/3rdparty/iossim_1_8_2/Info.plist b/src/tools/3rdparty/iossim_1_8_2/Info.plist new file mode 100644 index 0000000000..bc69bf3873 --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/Info.plist @@ -0,0 +1,16 @@ + + + + + CFBundlePackageType + APPL + CFBundleSignature + @TYPEINFO@ + CFBundleExecutable + @EXECUTABLE@ + CFBundleIdentifier + org.qt-project.qt-creator.iosTool + LSUIElement + 1 + + diff --git a/src/tools/3rdparty/iossim_1_8_2/iossim.qbs b/src/tools/3rdparty/iossim_1_8_2/iossim.qbs new file mode 100644 index 0000000000..1b96084e17 --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/iossim.qbs @@ -0,0 +1,30 @@ +import qbs 1.0 +import QtcTool + + +QtcTool { + name: "iossim" + condition: qbs.targetOS.contains("osx") + + Depends { name: "Qt"; submodules: ["widgets"] } + Depends { name: "app_version_header" } + + files: [ + "main.mm", + "nsprintf.mm", + "nsstringexpandpath.mm", + "iphonesimulator.mm", + "iphonesimulator.h", + "nsprintf.h", + "nsstringexpandpath.h", + "version.h", + "iphonesimulatorremoteclient/iphonesimulatorremoteclient.h" + ] + cpp.linkerFlags: base.concat(["-sectcreate", "__TEXT", "__info_plist", path + "/Info.plist", + "-fobjc-link-runtime"]) + cpp.frameworks: base.concat(["Foundation", "CoreServices", "ApplicationServices", "IOKit", + "AppKit"]) + cpp.frameworkPaths: base.concat("/System/Library/PrivateFrameworks") + + toolInstallDir: project.ide_libexec_path + "/ios" +} diff --git a/src/tools/3rdparty/iossim_1_8_2/iossim_1_8_2.pro b/src/tools/3rdparty/iossim_1_8_2/iossim_1_8_2.pro new file mode 100644 index 0000000000..9e30307406 --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/iossim_1_8_2.pro @@ -0,0 +1,55 @@ +CONFIG += console + +QT += core +QT += gui + +CONFIG -= app_bundle + +include(../../../../qtcreator.pri) + +# Prevent from popping up in the dock when launched. +# We embed the Info.plist file, so the application doesn't need to +# be a bundle. +QMAKE_LFLAGS += -sectcreate __TEXT __info_plist \"$$PWD/Info.plist\" \ + -fobjc-link-runtime + +LIBS += \ + -framework Foundation \ + -framework CoreServices \ + -framework ApplicationServices \ + -framework CoreFoundation \ + -F/System/Library/PrivateFrameworks \ + -framework IOKit -framework AppKit + +iPhoneSimulatorRemoteClientDirectLinking { + LIBS += \ + -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks \ + -F/Applications/Xcode.app/Contents/OtherFrameworks + LIBS += \ + -framework iPhoneSimulatorRemoteClient + QMAKE_RPATHDIR += /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks \ + /Applications/Xcode.app/Contents/OtherFrameworks + /System/Library/PrivateFrameworks \ +} + +TEMPLATE = app + +# put into a subdir, so we can deploy a separate qt.conf for it +DESTDIR = $$IDE_LIBEXEC_PATH/ios +include(../../../rpath.pri) + +OBJECTIVE_SOURCES += \ + main.mm \ + nsprintf.mm \ + nsstringexpandPath.mm \ + iphonesimulator.mm + +HEADERS += \ + iphonesimulator.h \ + nsprintf.h \ + nsstringexpandpath.h \ + version.h \ + iphonesimulatorremoteclient/iphonesimulatorremoteclient.h + +OTHER_FILES = IOSSIM_LICENSE \ + Info.plist diff --git a/src/tools/3rdparty/iossim_1_8_2/iphonesimulator.h b/src/tools/3rdparty/iossim_1_8_2/iphonesimulator.h new file mode 100644 index 0000000000..0770c50ee3 --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/iphonesimulator.h @@ -0,0 +1,41 @@ +/* Author: Landon Fuller + * Copyright (c) 2008-2011 Plausible Labs Cooperative, Inc. + * All rights reserved. + * + * See the IOSSIM_LICENSE file in this directory for the license on the source code in this file. + */ + +#import +#import "iphonesimulatorremoteclient/iphonesimulatorremoteclient.h" +#import "version.h" + +@interface iPhoneSimulator : NSObject { +@private + DTiPhoneSimulatorSystemRoot *sdkRoot; + NSFileHandle *stdoutFileHandle; + NSFileHandle *stderrFileHandle; + DTiPhoneSimulatorSession *session; + NSTimer *pidCheckingTimer; + BOOL startOnly; + BOOL exitOnStartup; + BOOL shouldWaitDebugger; + BOOL shouldStartDebugger; + BOOL useGDB; + BOOL verbose; + BOOL alreadyPrintedData; + BOOL retinaDevice; + BOOL tallDevice; +} + +- (id)init; +- (void)dealloc; +- (void)runWithArgc:(int)argc argv:(char **)argv; + +- (void)createStdioFIFO:(NSFileHandle **)fileHandle ofType:(NSString *)type atPath:(NSString **)path; +- (void)removeStdioFIFO:(NSFileHandle *)fileHandle atPath:(NSString *)path; +- (void)stop; +- (void)checkPid:(NSTimer *)timer; +- (void)doExit:(int)errorCode; +- (void)changeDeviceType:(NSString *)family retina:(BOOL)retina isTallDevice:(BOOL)isTallDevice; + +@end diff --git a/src/tools/3rdparty/iossim_1_8_2/iphonesimulator.mm b/src/tools/3rdparty/iossim_1_8_2/iphonesimulator.mm new file mode 100644 index 0000000000..b06b54276d --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/iphonesimulator.mm @@ -0,0 +1,566 @@ +/* Author: Landon Fuller + * Copyright (c) 2008-2011 Plausible Labs Cooperative, Inc. + * All rights reserved. + * + * See the IOSSIM_LICENSE file in this directory for the license on the source code in this file. + */ + +#import "iphonesimulator.h" +#import "nsstringexpandpath.h" +#import "nsprintf.h" +#import +#import +#import +#import + +NSString *simulatorPrefrencesName = @"com.apple.iphonesimulator"; +NSString *deviceProperty = @"SimulateDevice"; +NSString *deviceIphoneRetina3_5Inch = @"iPhone Retina (3.5-inch)"; +NSString *deviceIphoneRetina4_0Inch = @"iPhone Retina (4-inch)"; +NSString *deviceIphone = @"iPhone"; +NSString *deviceIpad = @"iPad"; +NSString *deviceIpadRetina = @"iPad (Retina)"; + +/** + * A simple iPhoneSimulatorRemoteClient framework. + */ +@implementation iPhoneSimulator + +- (id)init { + self = [super init]; + session = nil; + pidCheckingTimer = nil; + return self; +} + +- (void)dealloc { + [session release]; + [pidCheckingTimer release]; + [super dealloc]; +} + +- (void)doExit:(int)errorCode { + nsprintf(@"", errorCode); + nsprintf(@""); + fflush(stdout); + fflush(stderr); + exit(errorCode); +} + +- (void) printUsage { + fprintf(stdout, "Usage: iossim [--args ...]\n"); + fprintf(stdout, "\n"); + fprintf(stdout, "Commands:\n"); + fprintf(stdout, " showsdks List the available iOS SDK versions\n"); + fprintf(stdout, " launch Launch the application at the specified path on the iOS Simulator\n"); + fprintf(stdout, " start Launch iOS Simulator without an app\n"); + fprintf(stdout, "\n"); + fprintf(stdout, "Options:\n"); + fprintf(stdout, " --version Print the version of ios-sim\n"); + fprintf(stdout, " --developer-path path to the developer directory (in Xcode)"); + fprintf(stdout, " --help Show this help text\n"); + fprintf(stdout, " --verbose Set the output level to verbose\n"); + fprintf(stdout, " --exit Exit after startup\n"); + fprintf(stdout, " --wait-for-debugger Wait for debugger to attach\n"); + fprintf(stdout, " --debug Attach LLDB to the application on startup\n"); + fprintf(stdout, " --use-gdb Use GDB instead of LLDB. (Requires --debug)\n"); + fprintf(stdout, " --sdk The iOS SDK version to run the application on (defaults to the latest)\n"); + fprintf(stdout, " --family The device type that should be simulated (defaults to `iphone')\n"); + fprintf(stdout, " --retina Start a retina device\n"); + fprintf(stdout, " --tall In combination with --retina flag, start the tall version of the retina device (e.g. iPhone 5 (4-inch))\n"); + fprintf(stdout, " --uuid A UUID identifying the session (is that correct?)\n"); + fprintf(stdout, " --env A plist file containing environment key-value pairs that should be set\n"); + fprintf(stdout, " --setenv NAME=VALUE Set an environment variable\n"); + fprintf(stdout, " --stdout The path where stdout of the simulator will be redirected to (defaults to stdout of ios-sim)\n"); + fprintf(stdout, " --stderr The path where stderr of the simulator will be redirected to (defaults to stderr of ios-sim)\n"); + fprintf(stdout, " --timeout The timeout time to wait for a response from the Simulator. Default value: 30 seconds\n"); + fprintf(stdout, " --args <...> All following arguments will be passed on to the application\n"); + fflush(stdout); +} + + +- (int) showSDKs { + NSUInteger i; + id tClass = objc_getClass("DTiPhoneSimulatorSystemRoot"); + if (tClass == nil) { + nsprintf(@"DTiPhoneSimulatorSystemRoot class is nil."); + return EXIT_FAILURE; + } + NSArray *roots = [tClass knownRoots]; + + nsprintf(@""); + for (i = 0; i < [roots count]; ++i) { + DTiPhoneSimulatorSystemRoot *root = [roots objectAtIndex:i]; + nsprintf(@"sdk%d_name%@", i, [root sdkDisplayName]); + nsprintf(@"sdk%d_version%@", i, [root sdkVersion]); + nsprintf(@"sdk%d_sysroot%@", i, [root sdkRootPath]); + } + nsprintf(@""); + return EXIT_SUCCESS; +} + + +- (void)session:(DTiPhoneSimulatorSession *)mySession didEndWithError:(NSError *)error { + if (verbose) { + nsprintf(@"Session did end with error %@", error); + } + + if (stderrFileHandle != nil) { + NSString *stderrPath = [[mySession sessionConfig] simulatedApplicationStdErrPath]; + [self removeStdioFIFO:stderrFileHandle atPath:stderrPath]; + } + + if (stdoutFileHandle != nil) { + NSString *stdoutPath = [[mySession sessionConfig] simulatedApplicationStdOutPath]; + [self removeStdioFIFO:stdoutFileHandle atPath:stdoutPath]; + } + + if (error != nil) + [self doExit:EXIT_FAILURE]; + else + [self doExit:EXIT_SUCCESS]; +} + + +- (void)session:(DTiPhoneSimulatorSession *)mySession didStart:(BOOL)started withError:(NSError *)error { + if (startOnly && mySession) { + [NSTask launchedTaskWithLaunchPath:@"/usr/bin/osascript" + arguments:[NSArray arrayWithObjects:@"-e", @"tell application \"iPhone Simulator\" to activate", nil]]; + nsprintf(@"Simulator started (no session)"); + [self doExit:EXIT_SUCCESS]; + return; + } + if (started) { + [NSTask launchedTaskWithLaunchPath:@"/usr/bin/osascript" + arguments:[NSArray arrayWithObjects:@"-e", @"tell application \"iPhone Simulator\" to activate", nil]]; + if (shouldStartDebugger) { + char*args[4] = { NULL, NULL, (char*)[[[mySession simulatedApplicationPID] description] UTF8String], NULL }; + if (useGDB) { + args[0] = strdup("gdb"); + args[1] = strdup("program"); + } else { + args[0] = strdup("lldb"); + args[1] = strdup("--attach-pid"); + } + // The parent process must live on to process the stdout/stderr fifos, + // so start the debugger as a child process. + pid_t child_pid = fork(); + if (child_pid == 0) { + execvp(args[0], args); + } else if (child_pid < 0) { + nsprintf(@"Could not start debugger process: %@", errno); + [self doExit:EXIT_FAILURE]; + return; + } + } + if (verbose) { + nsprintf(@"Session started"); + } + nsprintf(@"%@", [session simulatedApplicationPID]); + fflush(stdout); + if (exitOnStartup) { + [self doExit:EXIT_SUCCESS]; + return; + } + pidCheckingTimer = [[NSTimer scheduledTimerWithTimeInterval:5.0 target:self + selector:@selector(checkPid:) userInfo:nil repeats: TRUE] retain]; + } else { + nsprintf(@"Session could not be started: %@", error); + [self doExit:EXIT_FAILURE]; + } +} + +- (void)stop { + if (session) + [session requestEndWithTimeout: 0.1]; +} + +- (void)checkPid:(NSTimer *)timer { + (void)timer; + if (session && [[session simulatedApplicationPID]intValue] > 0) { + if (kill((pid_t)[[session simulatedApplicationPID]intValue], 0) == -1) { + nsprintf(@"app stopped"); + [self doExit:EXIT_SUCCESS]; + return; + } + } +} +- (void)stdioDataIsAvailable:(NSNotification *)notification { + [[notification object] readInBackgroundAndNotify]; + NSData *data = [[notification userInfo] valueForKey:NSFileHandleNotificationDataItem]; + NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; /* dangerous if partially encoded data is at the boundary */ + if (!alreadyPrintedData) { + if ([str length] == 0) { + return; + } else { + alreadyPrintedData = YES; + } + } + if ([notification object] == stdoutFileHandle) { + printf("%s\n", [str UTF8String]); + } else { + nsprintf(@"%@", str); // handle stderr differently? + } + fflush(stdout); +} + + +- (void)createStdioFIFO:(NSFileHandle **)fileHandle ofType:(NSString *)type atPath:(NSString **)path { + *path = [NSString stringWithFormat:@"%@/ios-sim-%@-pipe-%d", NSTemporaryDirectory(), type, (int)time(NULL)]; + if (mkfifo([*path UTF8String], S_IRUSR | S_IWUSR) == -1) { + nsprintf(@"Unable to create %@ named pipe `%@'", type, *path); + [self doExit:EXIT_FAILURE]; + } else { + if (verbose) { + nsprintf(@"Creating named pipe at `%@'", *path); + } + int fd = open([*path UTF8String], O_RDONLY | O_NDELAY); + *fileHandle = [[[NSFileHandle alloc] initWithFileDescriptor:fd] retain]; + [*fileHandle readInBackgroundAndNotify]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(stdioDataIsAvailable:) + name:NSFileHandleReadCompletionNotification + object:*fileHandle]; + } +} + + +- (void)removeStdioFIFO:(NSFileHandle *)fileHandle atPath:(NSString *)path { + if (verbose) { + nsprintf(@"Removing named pipe at `%@'", path); + } + [fileHandle closeFile]; + [fileHandle release]; + if (![[NSFileManager defaultManager] removeItemAtPath:path error:NULL]) { + nsprintf(@"Unable to remove named pipe `%@'", path); + } +} + + +- (int)launchApp:(NSString *)path withFamily:(NSString *)family + uuid:(NSString *)uuid + environment:(NSDictionary *)environment + stdoutPath:(NSString *)stdoutPath + stderrPath:(NSString *)stderrPath + timeout:(NSTimeInterval)timeout + args:(NSArray *)args { + DTiPhoneSimulatorApplicationSpecifier *appSpec; + DTiPhoneSimulatorSessionConfig *config; + NSError *error = 0; + id tClass; + + NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + if (!startOnly && ![fileManager fileExistsAtPath:path]) { + nsprintf(@"Application path %@ doesn't exist!", path); + return EXIT_FAILURE; + } + + /* Create the app specifier */ + tClass = objc_getClass("DTiPhoneSimulatorApplicationSpecifier"); + if (tClass == nil) { + nsprintf(@"DTiPhoneSimulatorApplicationSpecifier class is nil."); + return EXIT_FAILURE; + } + appSpec = startOnly ? nil : [tClass specifierWithApplicationPath:path]; + + if (verbose) { + nsprintf(@"App Spec: %@", appSpec); + nsprintf(@"SDK Root: %@", sdkRoot); + + for (id key in environment) { + nsprintf(@"Env: %@ = %@", key, [environment objectForKey:key]); + } + } + + + NSString *sdkVersion = [sdkRoot sdkVersion]; + NSString *appSupportDir = [NSString stringWithFormat:@"%@/Library/Application Support/iPhone Simulator/%@", + NSHomeDirectory(), sdkVersion]; + NSMutableDictionary *mutableEnv = [NSMutableDictionary dictionaryWithDictionary:environment]; + [mutableEnv setObject:appSupportDir forKey:@"CFFIXED_USER_HOME"]; + [mutableEnv setObject:appSupportDir forKey:@"IPHONE_SHARED_RESOURCES_DIRECTORY"]; + [mutableEnv setObject:appSupportDir forKey:@"HOME"]; + [mutableEnv setObject:[sdkRoot sdkRootPath] forKey:@"IPHONE_SIMULATOR_ROOT"]; + [mutableEnv setObject:[sdkRoot sdkRootPath] forKey:@"DYLD_ROOT_PATH"]; + [mutableEnv setObject:[sdkRoot sdkRootPath] forKey:@"DYLD_FRAMEWORK_PATH"]; + [mutableEnv setObject:[sdkRoot sdkRootPath] forKey:@"DYLD_LIBRARY_PATH"]; + [mutableEnv setObject:@"YES" forKey:@"NSUnbufferedIO"]; + environment = mutableEnv; + + /* Set up the session configuration */ + tClass = objc_getClass("DTiPhoneSimulatorSessionConfig"); + if (tClass == nil) { + nsprintf(@"DTiPhoneSimulatorApplicationSpecifier class is nil."); + return EXIT_FAILURE; + } + config = [[[tClass alloc] init] autorelease]; + [config setApplicationToSimulateOnStart:appSpec]; + [config setSimulatedSystemRoot:sdkRoot]; + [config setSimulatedApplicationShouldWaitForDebugger:shouldWaitDebugger]; + + [config setSimulatedApplicationLaunchArgs:args]; + [config setSimulatedApplicationLaunchEnvironment:environment]; + + if (stderrPath) { + stderrFileHandle = nil; + } else if (!exitOnStartup) { + [self createStdioFIFO:&stderrFileHandle ofType:@"stderr" atPath:&stderrPath]; + } + [config setSimulatedApplicationStdErrPath:stderrPath]; + + if (stdoutPath) { + stdoutFileHandle = nil; + } else if (!exitOnStartup) { + [self createStdioFIFO:&stdoutFileHandle ofType:@"stdout" atPath:&stdoutPath]; + } + [config setSimulatedApplicationStdOutPath:stdoutPath]; + + [config setLocalizedClientName: @"iossim"]; + + // this was introduced in 3.2 of SDK + if ([config respondsToSelector:@selector(setSimulatedDeviceFamily:)]) { + if (family == nil) { + family = @"iphone"; + } + + if (verbose) { + nsprintf(@"using device family %@",family); + } + + if ([family isEqualToString:@"ipad"]) { +[config setSimulatedDeviceFamily:[NSNumber numberWithInt:2]]; + } else{ + [config setSimulatedDeviceFamily:[NSNumber numberWithInt:1]]; + } + } + + [self changeDeviceType:family retina:retinaDevice isTallDevice:tallDevice]; + + /* Start the session */ + tClass = objc_getClass("DTiPhoneSimulatorSession"); + if (tClass == nil) { + nsprintf(@"DTiPhoneSimulatorSession class is nil."); + return EXIT_FAILURE; + } + session = [[tClass alloc] init]; + [session setDelegate:self]; + if (uuid != nil){ + [session setUuid:uuid]; + } + + if (![session requestStartWithConfig:config timeout:timeout error:&error]) { + nsprintf(@"Could not start simulator session: %@", error); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} + +- (void) changeDeviceType:(NSString *)family retina:(BOOL)retina isTallDevice:(BOOL)isTallDevice { + NSString *devicePropertyValue; + if (retina) { + if (verbose) { + nsprintf(@"using retina"); + } + if ([family isEqualToString:@"ipad"]) { + devicePropertyValue = deviceIpadRetina; + } + else { + if (isTallDevice) { + devicePropertyValue = deviceIphoneRetina4_0Inch; + } else { + devicePropertyValue = deviceIphoneRetina3_5Inch; + } + } + } else { + if ([family isEqualToString:@"ipad"]) { + devicePropertyValue = deviceIpad; + } else { + devicePropertyValue = deviceIphone; + } + } + CFPreferencesSetAppValue((CFStringRef)deviceProperty, (CFPropertyListRef)devicePropertyValue, (CFStringRef)simulatorPrefrencesName); + CFPreferencesAppSynchronize((CFStringRef)simulatorPrefrencesName); +} + + +/** + * Execute 'main' + */ +- (void)runWithArgc:(int)argc argv:(char **)argv { + if (argc < 2) { + [self printUsage]; + exit(EXIT_FAILURE); + } + + retinaDevice = NO; + tallDevice = NO; + exitOnStartup = NO; + alreadyPrintedData = NO; + startOnly = strcmp(argv[1], "start") == 0; + nsprintf(@""); + + if (strcmp(argv[1], "showsdks") == 0) { + [self doExit:[self showSDKs]]; + return; + } else if (strcmp(argv[1], "launch") == 0 || startOnly) { + if (strcmp(argv[1], "launch") == 0 && argc < 3) { + nsprintf(@"Missing application path argument"); + [self printUsage]; + [self doExit:EXIT_FAILURE]; + return; + } + + NSString *appPath = nil; + int argOffset; + if (startOnly) { + argOffset = 2; + } + else { + argOffset = 3; + appPath = [[NSString stringWithUTF8String:argv[2]] expandPath]; + } + + NSString *family = nil; + NSString *uuid = nil; + NSString *stdoutPath = nil; + NSString *stderrPath = nil; + NSTimeInterval timeout = 30; + NSMutableDictionary *environment = [NSMutableDictionary dictionary]; + + int i = argOffset; + for (; i < argc; i++) { + if (strcmp(argv[i], "--version") == 0) { + printf("%s\n", IOS_SIM_VERSION); + exit(EXIT_SUCCESS); + } else if (strcmp(argv[i], "--help") == 0) { + [self printUsage]; + exit(EXIT_SUCCESS); + } else if (strcmp(argv[i], "--verbose") == 0) { + verbose = YES; + } else if (strcmp(argv[i], "--exit") == 0) { + exitOnStartup = YES; + } else if (strcmp(argv[i], "--wait-for-debugger") == 0) { + shouldWaitDebugger = YES; + } else if (strcmp(argv[i], "--debug") == 0) { + shouldWaitDebugger = YES; + shouldStartDebugger = YES; + } else if (strcmp(argv[i], "--use-gdb") == 0) { + useGDB = YES; + } else if (strcmp(argv[i], "--developer-path") == 0) { + ++i; + } else if (strcmp(argv[i], "--timeout") == 0) { + if (i + 1 < argc) { + timeout = [[NSString stringWithUTF8String:argv[++i]] doubleValue]; + NSLog(@"Timeout: %f second(s)", timeout); + } + } + else if (strcmp(argv[i], "--sdk") == 0) { + i++; + NSString* ver = [NSString stringWithCString:argv[i] encoding:NSUTF8StringEncoding]; + id tClass = objc_getClass("DTiPhoneSimulatorSystemRoot"); + NSArray *roots; + if (tClass == nil) { + nsprintf(@"DTiPhoneSimulatorSystemRoot class is nil."); + [self doExit:EXIT_FAILURE]; + return; + } + roots = [tClass knownRoots]; + for (DTiPhoneSimulatorSystemRoot *root in roots) { + NSString *v = [root sdkVersion]; + if ([v isEqualToString:ver]) { + sdkRoot = root; + break; + } + } + if (sdkRoot == nil) { + fprintf(stdout,"Unknown or unsupported SDK version: %s\n",argv[i]); + [self showSDKs]; + exit(EXIT_FAILURE); + } + } else if (strcmp(argv[i], "--family") == 0) { + i++; + family = [NSString stringWithUTF8String:argv[i]]; + } else if (strcmp(argv[i], "--uuid") == 0) { + i++; + uuid = [NSString stringWithUTF8String:argv[i]]; + } else if (strcmp(argv[i], "--setenv") == 0) { + i++; + NSArray *parts = [[NSString stringWithUTF8String:argv[i]] componentsSeparatedByString:@"="]; + [environment setObject:[parts objectAtIndex:1] forKey:[parts objectAtIndex:0]]; + } else if (strcmp(argv[i], "--env") == 0) { + i++; + NSString *envFilePath = [[NSString stringWithUTF8String:argv[i]] expandPath]; + environment = [NSDictionary dictionaryWithContentsOfFile:envFilePath]; + if (!environment) { + fprintf(stdout, "Could not read environment from file: %s\n", argv[i]); + [self printUsage]; + exit(EXIT_FAILURE); + } + } else if (strcmp(argv[i], "--stdout") == 0) { + i++; + stdoutPath = [[NSString stringWithUTF8String:argv[i]] expandPath]; + NSLog(@"stdoutPath: %@", stdoutPath); + } else if (strcmp(argv[i], "--stderr") == 0) { + i++; + stderrPath = [[NSString stringWithUTF8String:argv[i]] expandPath]; + NSLog(@"stderrPath: %@", stderrPath); + } else if (strcmp(argv[i], "--retina") == 0) { + retinaDevice = YES; + } else if (strcmp(argv[i], "--tall") == 0) { + tallDevice = YES; + } else if (strcmp(argv[i], "--args") == 0) { + i++; + break; + } else { + printf("unrecognized argument:%s\n", argv[i]); + [self printUsage]; + [self doExit:EXIT_FAILURE]; + return; + } + } + NSMutableArray *args = [NSMutableArray arrayWithCapacity:MAX(argc - i,0)]; + for (; i < argc; i++) { + [args addObject:[NSString stringWithUTF8String:argv[i]]]; + } + + if (sdkRoot == nil) { + id tClass = objc_getClass("DTiPhoneSimulatorSystemRoot"); + if (tClass == nil) { + nsprintf(@"DTiPhoneSimulatorSystemRoot class is nil."); + [self doExit:EXIT_FAILURE]; + return; + } + sdkRoot = [tClass defaultRoot]; + } + + /* Don't exit, adds to runloop */ + int res = [self launchApp:appPath + withFamily:family + uuid:uuid + environment:environment + stdoutPath:stdoutPath + stderrPath:stderrPath + timeout:timeout + args:args]; + nsprintf(@"", ((res == 0) ? @"SUCCESS" : @"FAILURE")); + fflush(stdout); + fflush(stderr); + if (res != 0) + [self doExit:EXIT_FAILURE]; + } else { + if (argc == 2 && strcmp(argv[1], "--help") == 0) { + [self printUsage]; + [self doExit:EXIT_SUCCESS]; + } else if (argc == 2 && strcmp(argv[1], "--version") == 0) { + printf("%s\n", IOS_SIM_VERSION); + [self doExit:EXIT_SUCCESS]; + } else { + fprintf(stdout, "Unknown command\n"); + [self printUsage]; + [self doExit:EXIT_FAILURE]; + } + } +} + +@end diff --git a/src/tools/3rdparty/iossim_1_8_2/iphonesimulatorremoteclient/iphonesimulatorremoteclient.h b/src/tools/3rdparty/iossim_1_8_2/iphonesimulatorremoteclient/iphonesimulatorremoteclient.h new file mode 100644 index 0000000000..abf69c8067 --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/iphonesimulatorremoteclient/iphonesimulatorremoteclient.h @@ -0,0 +1,126 @@ +#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 + * + * See the IOSSIM_LICENSE file in the parent directory for the license on the source code in this file. + */ + +@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/src/tools/3rdparty/iossim_1_8_2/main.mm b/src/tools/3rdparty/iossim_1_8_2/main.mm new file mode 100644 index 0000000000..fb83dc3e19 --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/main.mm @@ -0,0 +1,77 @@ +/* Author: Landon Fuller + * Copyright (c) 2008-2011 Plausible Labs Cooperative, Inc. + * All rights reserved. + * + * See the IOSSIM_LICENSE file in this directory for the license on the source code in this file. + */ +/* derived from https://github.com/phonegap/ios-sim */ +#import +#import "iphonesimulator.h" +#include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#else +#include +#endif +#include +#include + +/* to do: + * - try to stop inferior when killed (or communicate with creator to allow killing the inferior) + * - remove unneeded functionality and streamline a bit + */ + +/* + * Runs the iPhoneSimulator backed by a main runloop. + */ +int main (int argc, char *argv[]) { + int qtargc = 1; + char *qtarg = 0; + if (argc) + qtarg = argv[0]; +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QApplication a(qtargc, &qtarg); +#else + QGuiApplication a(qtargc, &qtarg); +#endif + + + //NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + QString xcodePath = QLatin1String("/Applications/Xcode.app/Contents/Developer/"); + for (int i = 0; i + 1 < argc; ++i) { + if (strcmp(argv[i], "--developer-path") == 0) + xcodePath = QString::fromLocal8Bit(argv[i + 1]); + } + if (!xcodePath.endsWith(QLatin1Char('/'))) + xcodePath.append(QLatin1Char('/')); + + /* manual loading of the private deps */ + QStringList deps = QStringList() + << QLatin1String("/System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols") + << QLatin1String("/System/Library/PrivateFrameworks/CoreSymbolication.framework/CoreSymbolication") + << (xcodePath + QLatin1String("../OtherFrameworks/DevToolsFoundation.framework/DevToolsFoundation")); + foreach (const QString &libPath, deps) { + QLibrary *lib = new QLibrary(libPath); + //lib->setLoadHints(QLibrary::ExportExternalSymbolsHint); + if (!lib->load()) + printf("error loading %s", libPath.toUtf8().constData()); + } + QLibrary *libIPhoneSimulatorRemoteClient = new QLibrary(xcodePath + + QLatin1String("Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/iPhoneSimulatorRemoteClient.framework/iPhoneSimulatorRemoteClient")); + //libIPhoneSimulatorRemoteClient->setLoadHints(QLibrary::ResolveAllSymbolsHint|QLibrary::ExportExternalSymbolsHint); + if (!libIPhoneSimulatorRemoteClient->load()) + printf("error loading iPhoneSimulatorRemoteClient"); + + iPhoneSimulator *sim = [[iPhoneSimulator alloc] init]; + + /* Execute command line handler */ + [sim runWithArgc: argc argv: argv]; + + /* Run the loop to handle added input sources, if any */ + + int res = a.exec(); + exit(res); + // [pool release]; + return 0; +} diff --git a/src/tools/3rdparty/iossim_1_8_2/nsprintf.h b/src/tools/3rdparty/iossim_1_8_2/nsprintf.h new file mode 100644 index 0000000000..cee7c00d28 --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/nsprintf.h @@ -0,0 +1,6 @@ +/* + * See the IOSSIM_LICENSE file in this directory for the license on the source code in this file. + */ +int nsvfprintf (FILE *stream, NSString *format, va_list args); +int nsfprintf (FILE *stream, NSString *format, ...); +int nsprintf (NSString *format, ...); diff --git a/src/tools/3rdparty/iossim_1_8_2/nsprintf.mm b/src/tools/3rdparty/iossim_1_8_2/nsprintf.mm new file mode 100644 index 0000000000..b7413f593c --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/nsprintf.mm @@ -0,0 +1,44 @@ +/* + * NSLog() clone, but writes to arbitrary output stream + * + * See the IOSSIM_LICENSE file in this directory for the license on the source code in this file. + */ + +#import +#import + +int nsvfprintf (FILE *stream, NSString *format, va_list args) { + int retval; + + NSString *str = (NSString *) CFStringCreateWithFormatAndArguments(NULL, NULL, (CFStringRef) format, args); + retval = fprintf(stream, "%s\n", [str UTF8String]); + [str release]; + + return retval; +} + +int nsfprintf (FILE *stream, NSString *format, ...) { + va_list ap; + int retval; + + va_start(ap, format); + { + retval = nsvfprintf(stream, format, ap); + } + va_end(ap); + + return retval; +} + +int nsprintf (NSString *format, ...) { + va_list ap; + int retval; + + va_start(ap, format); + { + retval = nsvfprintf(stdout, format, ap); + } + va_end(ap); + + return retval; +} diff --git a/src/tools/3rdparty/iossim_1_8_2/nsstringexpandpath.h b/src/tools/3rdparty/iossim_1_8_2/nsstringexpandpath.h new file mode 100644 index 0000000000..3eed139c0e --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/nsstringexpandpath.h @@ -0,0 +1,11 @@ +/* + * See the IOSSIM_LICENSE file in this directory for the license on the source code in this file. + */ + +#import + +@interface NSString (ExpandPath) + +- (NSString *)expandPath; + +@end diff --git a/src/tools/3rdparty/iossim_1_8_2/nsstringexpandpath.mm b/src/tools/3rdparty/iossim_1_8_2/nsstringexpandpath.mm new file mode 100644 index 0000000000..53f43e3c12 --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/nsstringexpandpath.mm @@ -0,0 +1,18 @@ +/* + * See the IOSSIM_LICENSE file in this directory for the license on the source code in this file. + */ + +#import "nsstringexpandpath.h" + +@implementation NSString (ExpandPath) + +- (NSString *)expandPath { + if ([self isAbsolutePath]) { + return [self stringByStandardizingPath]; + } else { + NSString *cwd = [[NSFileManager defaultManager] currentDirectoryPath]; + return [[cwd stringByAppendingPathComponent:self] stringByStandardizingPath]; + } +} + +@end diff --git a/src/tools/3rdparty/iossim_1_8_2/version.h b/src/tools/3rdparty/iossim_1_8_2/version.h new file mode 100644 index 0000000000..9f8c0dfc91 --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/version.h @@ -0,0 +1 @@ +#define IOS_SIM_VERSION "1.8.2m" -- cgit v1.2.1