@@ -109,6 +109,37 @@ -(void) LoadSimulatorFramework:(NSString*) developerDir {
109
109
return ;
110
110
}
111
111
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
+
112
143
113
144
// Finds the developer dir via xcode-select or the DEVELOPER_DIR environment
114
145
// variable.
@@ -537,6 +568,13 @@ - (void)runWithArgc:(int)argc argv:(char **)argv {
537
568
[self printUsage ];
538
569
exit (EXIT_FAILURE);
539
570
}
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
+ }
540
578
541
579
retinaDevice = NO ;
542
580
tallDevice = NO ;
0 commit comments