| DiskImages2.framework | |
|---|---|
| Private Framework | |
| com.apple.DiskImages2 | |
| Available | 14.0 – present |
| Class Prefix | DI |
DiskImages2 is a private system framework introduced in iOS 14, a successor to the original DiskImages framework, the main difference being that the original DiskImages framework was written in C while DiskImages2 was written in objective-c and centered around Object Oriented Programming.
Example code
The example code below shows a basic command line interface program to attach a .dmg disk image in Objective-C
// To compile for macOS: // clang main.m -fmodules -iframework /System/Library/PrivateFrameworks -framework DiskImages2 // To compile for iOS (download DiskImages2 tbd file first from https://headers.cynder.me): // xcrun -sdk iphoneos clang -arch arm64 -miphoneos-version-min=14.0 -Xlinker /path/to/DiskImages2.tbd @importFoundation; #define SWIFT_THROWS __attribute__((__swift_error__(nonnull_error))) @interface DIDeviceHandle : NSObject @property(nonnull,retain,nonatomic)NSString*BSDName; @property(readonly,nonatomic)NSUIntegerregEntryID; @property(nonatomic)BOOLhandleRefCount; @end NS_ASSUME_NONNULL_BEGIN @interface DIAttachParams : NSObject -(id)initWithURL:(NSURL*_Nonnull)arg1error:(NSError**_Nonnull)arg2SWIFT_THROWS; @end @interface DiskImages2 : NSObject // Attaches a Disk image with the given attach params +(BOOL)attachWithParams:(DIAttachParams*)paramhandle:(DIDeviceHandle*_Nullable*_Nullable)herror:(NSError**)errSWIFT_THROWS; @end NS_ASSUME_NONNULL_END intmain(intargc,char*argv[]){ printf("objc example started\n"); if(argc<2){ printf("usage: %s <path-to-disk-image>\n",argv[0]); return-1; } NSURL*dmgURL=[NSURLfileURLWithPath:@(argv[1])]; DIAttachParams*params=[[DIAttachParamsalloc]initWithURL:dmgURLerror:nil]; DIDeviceHandle*deviceAttached; [DiskImages2attachWithParams:paramshandle:&deviceAttachederror:nil]; if(deviceAttached){ printf("Attached dmg, BSD Name: %s\n",[deviceAttachedBSDName].UTF8String); }else{ fprintf(stderr,"couldn't get device handle\n"); return-1; } return0; }
