Skip to content

Commit 10d5396

Browse files
committed
Fixes #115 - Add Xcode version check for version 3.0.0
1 parent 4633fae commit 10d5396

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Source/iPhoneSimulator.m

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,37 @@ -(void) LoadSimulatorFramework:(NSString*) developerDir {
109109
return ;
110110
}
111111

112+
NSString* GetXcodeVersion() {
113+
// Go look for it via xcodebuild.
114+
NSTask* xcodeBuildTask = [[[NSTask alloc] init] autorelease];
115+
[xcodeBuildTask setLaunchPath:@"/usr/bin/xcodebuild"];
116+
[xcodeBuildTask setArguments:[NSArray arrayWithObject:@"-version"]];
117+
118+
NSPipe* outputPipe = [NSPipe pipe];
119+
[xcodeBuildTask setStandardOutput:outputPipe];
120+
NSFileHandle* outputFile = [outputPipe fileHandleForReading];
121+
122+
[xcodeBuildTask launch];
123+
NSData* outputData = [outputFile readDataToEndOfFile];
124+
[xcodeBuildTask terminate];
125+
126+
NSString* output =
127+
[[[NSString alloc] initWithData:outputData
128+
encoding:NSUTF8StringEncoding] autorelease];
129+
output = [output stringByTrimmingCharactersInSet:
130+
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
131+
if ([output length] == 0) {
132+
output = nil;
133+
} else {
134+
NSArray* parts = [output componentsSeparatedByCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
135+
if ([parts count] >= 2) {
136+
return parts[1];
137+
}
138+
}
139+
return output;
140+
}
141+
142+
112143

113144
// Finds the developer dir via xcode-select or the DEVELOPER_DIR environment
114145
// variable.
@@ -537,6 +568,13 @@ - (void)runWithArgc:(int)argc argv:(char **)argv {
537568
[self printUsage];
538569
exit(EXIT_FAILURE);
539570
}
571+
572+
NSString* xcodeVersion = GetXcodeVersion();
573+
if (!([xcodeVersion compare:@"6.0" options:NSNumericSearch] != NSOrderedAscending)) {
574+
nsprintf(@"You need to have at least Xcode 6.0 installed -- you have version %@.", xcodeVersion);
575+
nsprintf(@"Run 'xcode-select --print-path' to check which version of Xcode is enabled.");
576+
exit(EXIT_FAILURE);
577+
}
540578

541579
retinaDevice = NO;
542580
tallDevice = NO;

0 commit comments

Comments
 (0)