Getting CPU,RAM info using IOKit in swift - swift

I need to get information about CPU, RAM, Battery usage in mac application.
I can get all those information by using vm_stat,top,system_profiler using NSTask.
But I can't use those if I enable sandbox.
I can't find anything because the documentation for that is very poor(or I didn't find anything I guess).
So, what are the functions I can use to get the info about the system? Like using IOPowerSources.h I can get information about the Battery.
Can anyone guide me?
Thanks!

Related

Can we mount/unmount a device/disk/usb on Mac using Cocoa Swift?

I am trying to mount a device that was ejected/unmounted by this API
unmountAndEjectDevice(at:)
https://developer.apple.com/documentation/appkit/nsworkspace/1530469-unmountandejectdevice
but I am unable to find an API that can help me remount the disc that was ejected by the user or by that API.
A couple of things I discovered, are using Disk Arbitration API or by using IO Kit Family Storage but I am not sure how to use them and IOKit is a low-level api, so, I don't want to mess with that either unless it's the only way.
A last resort solution for me is using diskutil but I want to know if there is a cocoa swift way of doing it

Find number of battery charge cycles Swift

i want to build an app that tells the user the environmental impact of different products, and naturally i want to include the phone itself in this. to do this i want to know how much electricity my phone has used up over its lifetime to calculate the electrical consumption.
as such, im trying to work out how many times my battery has been charged (how many cycles) in swift. ive looked into the documentation for UIDevice.BatteryState but it doesnt seem to give me this info? i also found some info pointing me at IOKit but not much further, the apple doc that ive found said that its unsupported?
theres an app called CoconutFlavour that does this, and i can find the maximum capacity in the menus but i need to find it using Swift.
how do i find the number of cycles my battery has run through in Swift? which class am i looking for? please help.
As far as I know, Apple keeps the battery information of the phone in log-power-date.session File and this file contains phone information written in XML. It writes the information you want in <key>.com.apple.ioreport.BatterCycleCount </key> section.
This file is located in the analysis and data section of the phone's privacy section. But I don't know how you can get it with an app.

How to find the entire device's CPU consumption from my iPhone Application?

I'm trying to find the API's to get the CPU consumption of the entire device. Currently, I'm able to find out CPU consumed by my Application. But I'm not gettig any help for the device's CPU consumption. Any help would be appreciated..
Thanks in advance...
Although Apple does not provides such API's but I dont know if you can use below github code.
Though this code does not have what you want but may it help you. Go through below github link:
https://github.com/erica/uidevice-extension

iOS system data

I am developing an application where I need to know some of my iphone system information such as the cpu speed and above the list of processes in memory and the system log.
I have seen on AppleStore that there are some apps (Apple-approved) that display the data (Ex JustSys) then it means that Apple provides tools for information system of this type.
I tried searching on the net but could not find anything. Does anyone know how to get this info?
thanks
You should look at below link. Might be helpful for you
http://iphonesdkdev.blogspot.com/2009/01/source-code-get-hardware-info-of-iphone.html

Best options to integrate my application with the Nike+ features of the iPhone 4G

How can I integrate my application with the Nike+ features of the iPhone 4G. I want to access the data captured and send that to my own applications. There seems to be limited information available on this topic. Any help is greatly appreciated.
I actually created a PHP class that extracts data from the Nike+ service. It might be of use to you. You can find the download and documentation at http://nikeplusphp.org
Not sure how you would save authentication in your app, but this class would definitely give you access to literally everything Nike return back to their own apps and website. Well, everything I could find!
If you do have any issues with the class or anything is missing, please feel free to get in touch or contribute!