Created
June 29, 2015 19:23
-
-
Save michaelmcguire/25ae4d84d9bb139495cf to your computer and use it in GitHub Desktop.
Getting device list in Swift using libimobiledevice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
var i: CInt = 0 | |
var device_list: UnsafeMutablePointer<UnsafeMutablePointer<Int8>> = nil | |
idevice_get_device_list(&device_list, &i) | |
print("number of devices: \(i)") | |
let array = Array(UnsafeBufferPointer(start: device_list, count: Int(i))) | |
for var device in array { | |
if let deviceName = String.fromCString(device) { | |
print("\tdevice: \(deviceName)") | |
} | |
} | |
idevice_device_list_free(device_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try adding the source to the Xcode project then importing the libimobiledevice.h file into the bridging header