Can I find UUID of connected Iphone devices from the objective-c on the mac? Something of a list of connected Iphones trough the usb cable.
Try this:
[[UIDevice device] uniqueIdentifier]
for each of your connected devices.
Apple keeps the iPhone pretty locked down. I don't think you'd find it easy to query anything from the iPhone without some low level code over USB.
IS there a specific reason you need to do this? Can you not just look in the Organizer window in Xcode and see what devices are connected there? The Organizer shows the UUIDs and more information about connected devices, including crash longs, the iPhone's console, screenshots and provisioning.
Use the ioreg command, and grep the received results. A minimalist implementation:
- (NSString*)getConnectedIphoneUIID
{
NSTask *ioRegTask = [[NSTask alloc] init];
[ioRegTask setLaunchPath:@"/usr/sbin/ioreg"];
[ioRegTask setArguments:[NSArray arrayWithObjects:@"-Src",@"IOUSBDevice",nil]];
NSTask *grepTask = [[NSTask alloc] init];
[grepTask setLaunchPath:@"/usr/bin/grep"];
[grepTask setArguments:[NSArray arrayWithObjects:@"-i", @"usb serial number", nil]];
NSPipe *ioregToGrepPipe = [[NSPipe alloc] init];
[ioRegTask setStandardOutput:ioregToGrepPipe];
[grepTask setStandardInput:ioregToGrepPipe];
NSPipe *outputPipe = [[NSPipe alloc] init];
[grepTask setStandardOutput:outputPipe];
NSFileHandle *outputFileHandle = [[outputPipe fileHandleForReading] retain];
[ioRegTask launch];
[grepTask launch];
NSData *outputData = [[outputFileHandle readDataToEndOfFile] retain];
[ioRegTask release];
[grepTask release];
[outputData release];
NSString *nvcap = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding];
return nvcap;
}
I could incorporate more checks and further parse the results, to make sure it's really an iPhone, just in case there are more devices listed in there that have the "usb serial number" property set. Checking the "SupportsIPhoneOS" property would further confirm the device's identity. This way, I could actually build a list of connected iPhone/iPod devices, and get their UUID's from the "usb serial number" property.