@@ -1198,29 +1198,36 @@ - (void)installDeveloperDiskImageAtURL:(NSURL *)diskURL signatureURL:(NSURL *)si
11981198 {
11991199 return finish ([NSError errorWithMobileImageMounterError: err device: altDevice]);
12001200 }
1201-
1202- if (result)
1201+
1202+ plist_t errorDescriptionNode = plist_dict_get_item (result, " DetailedError" );
1203+ if (errorDescriptionNode != NULL )
12031204 {
1205+ char *errorDescription = NULL ;
1206+ plist_get_string_val (errorDescriptionNode, &errorDescription);
1207+
1208+ NSString *nsErrorDescription = @(errorDescription);
12041209 plist_free (result);
1205- }
1206-
1207- // Verify the installed developer disk is compatible with altDevice's operating system version.
1208- ALTDebugConnection *testConnection = [[ALTDebugConnection alloc ] initWithDevice: altDevice];
1209- [testConnection connectWithCompletionHandler: ^(BOOL success, NSError * _Nullable error) {
1210- [testConnection disconnect ];
12111210
1212- if (success)
1211+ NSError *returnError = nil ;
1212+
1213+ if ([nsErrorDescription containsString: @" Failed to verify" ])
12131214 {
1214- // Connection succeeded, so we assume the developer disk is compatible.
1215- finish (nil );
1215+ // iOS device needs to be rebooted in order to mount disk to /Developer.
1216+ NSString *recoverySuggestion = [NSString stringWithFormat: NSLocalizedString(@" Please reboot %@ and try again." , @" " ), altDevice.name];
1217+
1218+ // ALTServerErrorUnderlyingError uses its underlying error's failure reason as its error description (if one exists),
1219+ // so assign our recovery suggestion to NSLocalizedFailureReasonErrorKey to make sure it's always displayed on client.
1220+ NSError *underlyingError = [NSError errorWithDomain: AltServerConnectionErrorDomain code: ALTServerConnectionErrorUnknown userInfo: @{NSLocalizedFailureReasonErrorKey : recoverySuggestion}];
1221+
1222+ returnError = [NSError errorWithDomain: AltServerErrorDomain code: ALTServerErrorUnderlyingError userInfo: @{NSUnderlyingErrorKey : underlyingError}];
12161223 }
1217- else if ([error.domain isEqualToString: AltServerConnectionErrorDomain] && error. code == ALTServerConnectionErrorUnknown)
1224+ else
12181225 {
1219- // Connection failed with .unknown error code, so we assume the developer disk is NOT compatible.
1226+ // Installation failed, so we assume the developer disk is NOT compatible with this iOS version.
1227+
12201228 NSMutableDictionary *userInfo = [@{
12211229 ALTOperatingSystemVersionErrorKey: NSStringFromOperatingSystemVersion(altDevice.osVersion ),
12221230 NSFilePathErrorKey : diskURL.path ,
1223- NSUnderlyingErrorKey : error,
12241231 } mutableCopy];
12251232
12261233 NSString *osName = ALTOperatingSystemNameForDeviceType (altDevice.type );
@@ -1229,8 +1236,22 @@ - (void)installDeveloperDiskImageAtURL:(NSURL *)diskURL signatureURL:(NSURL *)si
12291236 userInfo[ALTOperatingSystemNameErrorKey] = osName;
12301237 }
12311238
1232- NSError *returnError = [NSError errorWithDomain: AltServerErrorDomain code: ALTServerErrorIncompatibleDeveloperDisk userInfo: userInfo];
1233- finish (returnError);
1239+ returnError = [NSError errorWithDomain: AltServerErrorDomain code: ALTServerErrorIncompatibleDeveloperDisk userInfo: userInfo];
1240+ }
1241+
1242+ return finish (returnError);
1243+ }
1244+
1245+ plist_free (result);
1246+
1247+ // Verify that the developer disk has been successfully installed.
1248+ ALTDebugConnection *testConnection = [[ALTDebugConnection alloc ] initWithDevice: altDevice];
1249+ [testConnection connectWithCompletionHandler: ^(BOOL success, NSError * _Nullable error) {
1250+ [testConnection disconnect ];
1251+
1252+ if (success)
1253+ {
1254+ finish (nil );
12341255 }
12351256 else
12361257 {
0 commit comments