Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Guide the user to use Xcode's scheme auto creation feature when no sc…

…hemes are detected
  • Loading branch information...
commit c9e6a4d9044cae61a30bc6c38eea5541e9537652 1 parent a0c3fcf
@ndfred ndfred authored
Showing with 33 additions and 4 deletions.
  1. +33 −4 xctool/xctool/Options.m
View
37 xctool/xctool/Options.m
@@ -390,18 +390,47 @@ - (BOOL)validateAndReturnXcodeSubjectInfo:(XcodeSubjectInfo **)xcodeSubjectInfoO
[schemeNames addObject:[[schemePath lastPathComponent] stringByDeletingPathExtension]];
}
+ BOOL automaticSchemeCreationDisabled = NO;
+
+ {
+ NSString *basePath = self.project != nil ? self.project : self.workspace;
+ NSString *settingsPath = [basePath stringByAppendingPathComponent:@"/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings"];
+ NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:settingsPath];
+ NSNumber *automaticSchemeCreationSetting = [settings objectForKey:@"IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded"];
+
+ if (automaticSchemeCreationSetting != nil && [automaticSchemeCreationSetting isKindOfClass:[NSNumber class]]) {
+ automaticSchemeCreationDisabled = ![automaticSchemeCreationSetting boolValue];
+ }
+ }
+
+ NSString *schemeCreationTip = @""
+ @"\n\nTIP: This might happen if you're relying on Xcode to autocreate your schemes\n"
+ @"and your scheme files don't yet exist. xctool, like xcodebuild, isn't able to\n"
+ @"automatically create schemes. We recommend disabling \"Autocreate schemes\"\n"
+ @"in your workspace/project, making sure your existing schemes are marked as\n"
+ @"\"Shared\", and making sure they're checked into source control.";
+
if ([schemeNames count] == 0) {
*errorMessage = [NSString stringWithFormat:
- @"Cannot find schemes. Please consider creating shared schemes in Xcode.\n"
- @"See https://github.com/facebook/xctool#known-issues--tips for more information."];
+ @"Cannot find schemes. Please consider creating shared schemes in Xcode."];
+
+ if (!automaticSchemeCreationDisabled) {
+ *errorMessage = [*errorMessage stringByAppendingString:schemeCreationTip];
+ }
+
return NO;
}
if (![schemeNames containsObject:self.scheme]) {
*errorMessage = [NSString stringWithFormat:
- @"Can't find scheme '%@'. Possible schemes include: %@",
+ @"Can't find scheme '%@'.\n\nPossible schemes include:\n %@",
self.scheme,
- [schemeNames componentsJoinedByString:@", "]];
+ [schemeNames componentsJoinedByString:@"\n "]];
+
+ if (!automaticSchemeCreationDisabled) {
+ *errorMessage = [*errorMessage stringByAppendingString:schemeCreationTip];
+ }
+
return NO;
}
Please sign in to comment.
Something went wrong with that request. Please try again.