Post not yet marked as solved
Hi, i am working on a swift package library that gets information about all the disks connected to the mac and displays it organised into a tree structure, including the non-mounted storage devices attached to the machine.
My question is how can i get informations about unmounted devices like:
The amount of free space (when possible) of a partition or an APFS container
The space occupied by a single APFS volume
I am already using a combination of IOKit and Disk Arbitration for my library and i don't see this information anywhere in those frameworks, including the description dictionaries provided by Disk Arbitration.
Instead the terminal command diskutil info -plist [volume/partition BSD name here] gives me this info, but i can't just use it's output in my swift program (and obtaining it via a process object for example) since it doesn't work with the app sandbox, so i am looking for a sandbox-friendly way using just the API.
I hope you can help me figure this out, really any help is appreciated, thank you for your attention.
Post not yet marked as solved
Hi, i have made some code in Swift that allows me to get a list of the storage disks and the relative partitions present in a mac (everything made using the IOKit api), this of course includes the APFS containers that are managed by the OS as separate storage devices.
To have a proper representation of the partitions tree in my code i need to know which are the actual partitions housing a given APFS container.
I have tried to look for this information on documentation and on the internet, then into the IORegistry (using the registry explorer app) and searching for this info into the description dictionaries provided by Disk arbitration but so far no luck, even by comparing the UUIDs.
In IORegistry explorer in the IOService plane I can also see that the APFS Container in my mac's ssd is listed as a sub-node of it's physical storage a partition, but since i am using an IOIterator object to scan the IORegistry i have no idea of how i should look into sub-nodes for a given node.
Also i think that some particular storage configurations might have an APFS container split across multiple physical storage devices, in fact the diskutil list -plist command shows the physical store for each APFS containers as an array in the plist output, so the child approach might not be effective there.
So how can i do this?
I am doing all of this stuff because i am working to a sandbox-friendly open source swift package for macOS apps to easily get a complete tree structure of disks and partitions, in a similar fashion to the above mentioned diskutil list -plist command, my goal is actually to have the exact same structure provided by that command, with the same info.
Post not yet marked as solved
Hi developers, i need some help to let my app to work as it's supposed to do in the guidelines, i am creating a swift app which is a GUI for a command line tool but this command line tool does require to be run with sudo or by the root user, so to run it am temporarely using a not safe system which is just using a Process object to lunch a script with the sh executable to aks the user for the sudo password and then give that poassowrd to the sudo command and launch the command line tool, but i know that the proper way to that is by using an xpc service and then let the xpc service to do all the privilaged job, whithou having my app to deal with user credentials, but i need something for pure swift apps, i understand little to nothing of objective-c and i am also making this app in pure swift to be future proof, so i need you help to make that possible using pure swift.the only things i have found are the autherization samples from apple which are in objective-c only and as i mentioned, i do not understand objective-c.i need that the xpc service starts in a precise moment, when the uses clicks a specific button and then the app should pass the location of the command line tool, and the arguments to run it to the xpc service, and the wait until the xpc service ends it's job of running the executable, which can take also several minutes, after it's finished it will give back to the app some information, which are the full output ot the command lind tool and then it's exit code, becuase i need that data to determinate if the has done correctly his job and in case of error, which error it is, and to determinate that i use a combination of output analisys and kown exit codes.And also i preffer that the code is swift 3 compatible because i am stiil using xcode 8, and it should run also on yosemite which is one of mine development targets, because much potetial users for my app are still running older versions of macOS.the command line tool is not made by me and it's closed source, it's the "createinstallmedia" executable from apple's mac os installer apps, and i am attempting to create a tool to create a mac os bootable usb installer in a noob-friendly way using apple's official method and to pubblish it on the app store when it will be ready, and of course it will be open source and free for everyone.So i'd like much to have your help because i couldn't find anything elsewhere, thank very much for your interest in helping me.