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) |
I know this is old, but how did you get libimobiledevice to link with Swift properly? I have everything installed (
ideviceinfo
works), but adding libimobiledevice.dylib as a dependency in Xcode doesn't make it available in Swift. I wouldn't normally bother you but I couldn't find anything online.
Try adding the source to the Xcode project then importing the libimobiledevice.h file into the bridging header
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know this is old, but how did you get libimobiledevice to link with Swift properly? I have everything installed (
ideviceinfo
works), but adding libimobiledevice.dylib as a dependency in Xcode doesn't make it available in Swift. I wouldn't normally bother you but I couldn't find anything online.