I get the following errors when running the code below in a sandboxed app (it works when not sandboxed) and I have the com.apple.security.device.usb entitlement enabled.
Error:Unable to open io_service_t object and create user client. with reason: IOServiceOpen failed.
Error Domain=IOUSBHostErrorDomain Code=-536870174 "Failed to create IOUSBHostObject." UserInfo={NSLocalizedRecoverySuggestion=, NSLocalizedDescription=Failed to create IOUSBHostObject., NSLocalizedFailureReason=IOServiceOpen failed.}
import Foundation
import IOKit
import IOKit.usb
import IOKit.usb.IOUSBLib
import IOKit.serial
import IOUSBHost
import IOUSBHost.IOUSBHostInterface
class USBService {
enum UsbError: Error {
case noDeviceMatched
case deviceCriteriaNotUnique
}
init() {
}
func getDevice(idVendor: Int?, idProduct: Int?) throws {
let deviceSearchPattern: [IOUSBHostMatchingPropertyKey : Int] = [
.vendorID : idVendor!,
.productID : idProduct!,
]
let deviceDomain = [ "IOProviderClass": "IOUSBHostDevice" ]
let searchRequest = (deviceSearchPattern as NSDictionary).mutableCopy() as! NSMutableDictionary
searchRequest.addEntries(from: deviceDomain)
let service = IOServiceGetMatchingService(kIOMasterPortDefault, searchRequest)
guard service != 0 else {
throw UsbError.noDeviceMatched
}
let device = try IOUSBHostDevice.init(__ioService: service, options: [], queue: nil, interestHandler: nil)
print(device.deviceDescriptor?.pointee.idProduct)
}
}
Post
Replies
Boosts
Views
Activity
I'd like some help to structure navigation so that I can have an app that:
shows a sidebar view with a default detail view when it opens
clicking on each sidebar item loads the details view
clicking on an item in the details views pushes a full width view (without sidebar visible)
I just don't get how to use NavigationView to achieve this and none of the tutorials I've seen does something similar.
I've been stuck for quite a while on this and some guidance would save my week!
Thanks.
My app will have a concept of "packs" and the lessons inside the packs are interactive music learning experiences interacting with midi instruments (not always, only if the user has one, otherwise they can click around the virtual instrument on the UI).
I want to build it in a way that users download each one as if it was a Swift Playgrounds book. This would allow for a leaner app and not having a huge binary.
Constraints: App will be served on the app store
Related: I think I could achieve this using json config and having already views in the app that read the config and render the correct UI flow
I also saw this gist - https://gist.github.com/chriseidhof/26768f0b63fa3cdf8b46821e099df5ff that runs from the cli and got intriguided
Is this possible and allowed for apps in the App Store?
Cheers for any replies.