Skip to content

Commit 2f5162f

Browse files
ivanhernandez13gabebear
authored andcommitted
Fix json output for the installation callback and add json output when finding DeveloperDiskImage.dmg fails. (#438)
Fix json output for the installation callback and add json output for when finding DeveloperDiskImage.dmg
1 parent e4697e8 commit 2f5162f

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/ios-deploy/ios-deploy.m

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void NSLogJSON(NSDictionary* jsonDict) {
192192
[jsonString writeToFile:@"/dev/stdout" atomically:NO encoding:NSUTF8StringEncoding error:nil];
193193
[jsonString release];
194194
} else {
195-
[@"{\"error\": \"JSON error\"}" writeToFile:@"/dev/stdout" atomically:NO encoding:NSUTF8StringEncoding error:nil];
195+
[@"{\"JSONError\": \"JSON error\"}" writeToFile:@"/dev/stdout" atomically:NO encoding:NSUTF8StringEncoding error:nil];
196196
}
197197
}
198198
}
@@ -531,8 +531,14 @@ CFStringRef copy_device_support_path(AMDeviceRef device, CFStringRef suffix) {
531531
CFRelease(version_parts);
532532
CFRelease(build);
533533
CFRelease(deviceClass);
534-
if (path == NULL)
535-
on_error([NSString stringWithFormat:@"Unable to locate DeviceSupport directory with suffix '%@'. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!", suffix]);
534+
if (path == NULL) {
535+
NSString *msg = [NSString stringWithFormat:@"Unable to locate DeviceSupport directory with suffix '%@'. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown!", suffix];
536+
NSLogJSON(@{
537+
@"Event": @"DeviceSupportError",
538+
@"Status": msg,
539+
});
540+
on_error(msg);
541+
}
536542

537543
time( &endTime );
538544
NSLogVerbose(@"DeviceSupport directory '%@' was located. It took %.2f seconds", path, difftime(endTime,startTime));
@@ -642,11 +648,19 @@ mach_error_t install_callback(CFDictionaryRef dict, int arg) {
642648
(__bridge NSString *)status;
643649

644650
NSLogOut(@"[%3d%%] %@", overall_percent, status_with_path);
645-
NSLogJSON(@{@"Event": @"BundleInstall",
646-
@"OverallPercent": @(overall_percent),
647-
@"Percent": @(percent),
648-
@"Status": status_with_path
649-
});
651+
652+
NSMutableDictionary *jsonOutput = [@{
653+
@"Event": @"BundleInstall",
654+
@"OverallPercent": @(overall_percent),
655+
@"Percent": @(percent),
656+
@"Status": (__bridge NSString *)status
657+
} mutableCopy];
658+
if (path != NULL) {
659+
[jsonOutput setValue:(__bridge NSString *)path forKey:@"Path"];
660+
}
661+
662+
NSLogJSON(jsonOutput);
663+
[jsonOutput release];
650664
return 0;
651665
}
652666

0 commit comments

Comments
 (0)