Post

Replies

Boosts

Views

Activity

Can't get Driver properties using IORegistryEntryCreateCFProperties on iPadOS 16.1
We are developing our Driver using DriverKit. In client App we successfully discover our driver but can't get IORegistry properties except IOClass. So in a client App we use following code to read properties:     private func debugRegistry(device: io_object_t) {         var dictionary: Unmanaged<CFMutableDictionary>?         IORegistryEntryCreateCFProperties(device, &dictionary, kCFAllocatorDefault, .zero)         if let dictionary = dictionary {             let values = dictionary.takeUnretainedValue()             print(values)         }     } output is: {     IOClass = IOUserService; } We tested same code on macOS and output contains about 20+ properties. It looks like IOKi doesn't allow to read other properties except IOClass. Environment: Xcode - Version 14.1 beta 2 (14B5024i). iPadOS - iOS 16.1 (20B5050f)
1
1
1.1k
Sep ’22
Open UIApplication.openSettingsURLString doesn't navigate to App's settings
We are building iPadOS App that uses bundled DriveKit driver to communicate with USB device. This bundled driver should be enabled first by user from App's settings or Privacy & Security page. We read in Apple Docs that openSettingsURLString is recommended way to navigate user to App's settings. We added alert that is shown on App launch and has option to open settings. Our solution perfectly works on local DEBUG build. So user is navigated to App's settings when he click "Open Settings". However it doesn't work for TestFlight/App Store builds. "Open Settings" just opens system Settings app on some random page. Code: let settingsURL = URL(string: UIApplication.openSettingsURLString)! UIApplication.shared.open(settingsURL) Environment: Xcode Version 14.1(14B47b) iPadOS 16.1.1(20B101) Note: Our Settings.bundle contains Root.plist with no custom settings: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict/> </plist> We read speculations that some permission request should be triggered before navigation. Unfortunately, there is no API that checks or requests permission for DriverKit in the moment.
0
1
1.2k
Dec ’22
Can't add custom property into IORegistry on iPadOS 16
We are developing driver for our USB device. Our approach is to run and test driver on macOS first and then verify on iPadOS 16. In the driver we add custom property -"kUSBSerialNumberString" into default properties: OSDictionary * Driver::devicePropertiesWithSerialNumber() {     kern_return_t ret;     OSDictionary *properties = NULL;     OSDictionary *dictionary = NULL;     OSObjectPtr value;     const IOUSBDeviceDescriptor *deviceDescriptor;     deviceDescriptor = ivars->device->CopyDeviceDescriptor();          ret = CopyProperties(&properties);     value = copyStringAtIndex(deviceDescriptor->iSerialNumber, kIOUSBLanguageIDEnglishUS);     Log("Serial number: %{public}s", ((OSString *)value)->getCStringNoCopy());          dictionary = OSDictionary::withDictionary(properties, 0);     OSSafeReleaseNULL(properties);     if (value) {         OSDictionarySetValue(dictionary, "kUSBSerialNumberString", value);         OSSafeReleaseNULL(value);     }     return  dictionary; } next in kern_return_t IMPL(Driver, Start) we call SetProperties:     ret = SetProperties(devicePropertiesWithSerialNumber());     if(ret != kIOReturnSuccess) {         Log("Start() - Failed to set properties: 0x%08x.", ret);         goto Exit;     } We can read our property on macOS using:     func getDeviceProperty(device: io_object_t, key: String) -> AnyObject? {         IORegistryEntryCreateCFProperty(             device, key as CFString, kCFAllocatorDefault, .zero         )?.takeRetainedValue()     }         if let serialNumber = getDeviceProperty(device: driver, key: "kUSBSerialNumberString") {             print("serialNumber: \(serialNumber)")         } However getDevicePropertyon iPadOS returns nil. We are wondering is any limitation for IORegistry entries(properties) on iPadOS16? Is any way to add custom property to IORegistry? BTW, we added debug method to print all the available properties for IORegistry:     private func debugRegistry(device: io_object_t) {         var dictionary: Unmanaged<CFMutableDictionary>?         IORegistryEntryCreateCFProperties(device, &dictionary, kCFAllocatorDefault, .zero)         if let dictionary = dictionary {             let values = dictionary.takeUnretainedValue()             print(values)         }     } It returns just 1 property for iPadOS: { IOClass = IOUserService; } and much more for macOS including our custom one: { CFBundleIdentifier = "****"; CFBundleIdentifierKernel = "com.apple.kpi.iokit"; IOClass = IOUserService; IOMatchCategory = "***"; IOMatchedPersonality = { CFBundleIdentifier = "****"; CFBundleIdentifierKernel = "com.apple.kpi.iokit"; IOClass = IOUserService; IOMatchCategory = "****"; IOPersonalityPublisher = "****"; IOProviderClass = IOUSBHostInterface; IOResourceMatch = IOKit; IOUserClass = Driver; IOUserServerCDHash = 9cfd03b5c1b90da709ffb1455a053c5d7cdf47ac; IOUserServerName = "*****"; UserClientProperties = { IOClass = IOUserUserClient; IOUserClass = DriverUserClient; }; bConfigurationValue = 1; bInterfaceNumber = 1; bcdDevice = 512; idProduct = XXXXX; idVendor = XXXXX; }; IOPersonalityPublisher = "*****"; IOPowerManagement = { CapabilityFlags = 2; CurrentPowerState = 2; MaxPowerState = 2; }; IOProbeScore = 100000; IOProviderClass = IOUSBHostInterface; IOResourceMatch = IOKit; IOUserClass = Driver; IOUserServerCDHash = 9cfd03b5c1b90da709ffb1455a053c5d7cdf47ac; IOUserServerName = "*****"; UserClientProperties = { IOClass = IOUserUserClient; IOUserClass = DriverUserClient; }; bConfigurationValue = 1; bInterfaceNumber = 1; bcdDevice = 512; idProduct = XXXXX; idVendor = XXXXXX; kUSBSerialNumberString = XXXXXXXXXXX; }
2
4
1.5k
Sep ’23
XCUIElement's click is broken in iOS 17 simulator
Based on official docs click is available for iPadOS apps. We utilized click action to create universal UITests for macOS and iPadOS targets. It works fine on iPadOS 16.x but, unfortunately, stops to work in iOS 17 simulators for iPad. Environment: MacOS - 13.5.2 (22G91). Xcode - Version 15.0 (15A240d). Simulator - Version 15.0 (1015.2). SimulatorKit 935.1. CoreSimulator 920.6. Steps to reproduce: Create new multiplatform app Add simple button. For example: struct ContentView: View { @State var title = "Click Me" var body: some View { VStack { Button(title) { title = "Clicked" } .background(Color.blue) .foregroundColor(.white) } .padding() } } Add UITest that clicks on button. For example: func testClick() throws { let app = XCUIApplication() app.launch() app.buttons["Click Me"].click() XCTAssertTrue(app.buttons["Clicked"].exists) } Expected result: test is passed Actual result: test is failed since buttons["Click Me"].click() doesn't click in button. Workaround: Replacement .click() to .tap() fixes the issue but it makes impossible to create universal tests with single action for both platforms
0
2
568
Oct ’23
LazyVStack produces `AttributeGraph: cycle detected through attribute` when used in sheet
struct SheetView: View { @Binding var showSheet: Bool var body: some View { LazyVStack { Button("Dismiss") { showSheet.toggle() } } } } struct ContentView: View { @State private var showSheet = false var body: some View { Button("Show") { showSheet.toggle() } .sheet(isPresented: $showSheet) { SheetView(showSheet: $showSheet) } } } Xcode displays === AttributeGraph: cycle detected through attribute 119104 === message in console when SheetView is presented on screen. Environment: macOS 14.4.1 Xcode: Version 15.2
1
2
618
Apr ’24
Cannot communicate with DriverKit extension from macOs App due to IOServiceOpen error
We inspired by announce that DriverKit will come to iPadOs this fall and decided to experiment with DriverKit on macOS. We started from scratch but followed all the recommendations from Sample. With our installer code we can: Install driver extension to macOS system. (systemextensionsctl list shows [activated enabled]) for our driver See driver record using ioreg. So it's displayed: MyDriver <class IOUserService, id 0x10000193b, registered, matched, active, busy 0 (0 ms), retain 7> See *.MyDriver process in Activity Monitor In client code we can find a match: private let dextIdentifier = "MyDriver" private var lastResult: kern_return_t = kIOReturnSuccess private var connection: io_connect_t = IO_OBJECT_NULL var iterator: io_iterator_t = IO_OBJECT_NULL var driver: io_service_t = IO_OBJECT_NULL lastResult = IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceNameMatching(dextIdentifier), &iterator) print("Search for services ...") while case let service = IOIteratorNext(iterator), service != IO_OBJECT_NULL { driver = service } IOObjectRelease(iterator) guard driver != IO_OBJECT_NULL else { return } So driver is not IO_OBJECT_NULL. But we stuck on IOServiceOpen. So code: lastResult = IOServiceOpen(driver, mach_task_self_, UInt32(kIOHIDServerConnectType), &connection); validateLastResult(forOperation: "opening service") prints opening service: (iokit/common) general error since IOServiceOpen returns 0x2bc What we tried: Disable SIP in recovery mode and set systemextensionsctl developer on Result: opening service: (iokit/common) general error Add com.apple.developer.driverkit.userclient-access to our client App. Result: App crashes on start and in Console we see: taskgated-helper - Unsatisfied entitlements: com.apple.developer.driverkit.userclient-access. We requested this entitlement. We found post were com.apple.developer.driverkit.allow-any-userclient-access suggested as solution. Result: Driver extension is not started and we see in Console: taskgated-helper MyDriver: Unsatisfied entitlements: com.apple.developer.driverkit.allow-any-userclient-access amfid /Library/SystemExtensions/B7624EEF-3688-4735-A58B-26FEF4DE353C/MyDriver.dext/MyDriver signature not valid: -67671 We recreated appIds, profiles on developer account that has com.apple.developer.driverkit.allow-any-userclient-access from Apple. Result: Driver extension is started but we still see opening service: (iokit/common) general error We modified CommunicatingBetweenADriverKitExtensionAndAClientApp.zip by setting our appIds and profiles and run in in SIP disabled mode. Result: opening service: (iokit/common) general error Our environment: macOS Monterey 12.4 XCode Version 13.4 (13F17a) Driver Code is pretty straightforward: ///// iig class MyDriver: public IOUserClient { public: virtual bool init(void) override; virtual kern_return_t Start(IOService * provider) override; virtual kern_return_t Stop(IOService* provider) override; virtual void free(void) override; }; ///// cpp #define Log(fmt, ...) os_log(OS_LOG_DEFAULT, "MyDriver - " fmt "\n", ##__VA_ARGS__) struct MyDriver_IVars { OSAction* callbackAction = nullptr; }; bool MyDriver::init() { bool result = false; Log("init()"); result = super::init(); if (result != true) { Log("init() - super::init failed."); goto Exit; } ivars = IONewZero(MyDriver_IVars, 1); if (ivars == nullptr) { Log("init() - Failed to allocate memory for ivars."); goto Exit; } Log("init() - Finished."); return true; Exit: return false; } kern_return_t IMPL(MyDriver, Start) { kern_return_t ret; ret = Start(provider, SUPERDISPATCH); if(ret != kIOReturnSuccess) { Log("Start() - super::Start failed with error: 0x%08x.", ret); goto Exit; } ret = RegisterService(); if (ret != kIOReturnSuccess) { Log("Start() - Failed to register service with error: 0x%08x.", ret); goto Exit; } Log("Start() - Finished."); ret = kIOReturnSuccess; Exit: return ret; } kern_return_t IMPL(MyDriver, Stop) { kern_return_t ret = kIOReturnSuccess; Log("Stop()"); ret = Stop(provider, SUPERDISPATCH); if (ret != kIOReturnSuccess) { Log("Stop() - super::Stop failed with error: 0x%08x.", ret); } return ret; } void MyDriver::free(void) { Log("free()"); IOSafeDeleteNULL(ivars, MyDriver_IVars, 1); super::free(); }
2
3
2.2k
Jun ’22
macOS Sequoia doesn't respect Full Disk Access for UITests-Runner
We develop and test App for macOS. We start to see system alert - "UlTests-Runner" would like to access data from other apps on each UITest run. Our test suite does cleanup of files generated by App so we need access outside of UITests-Runner sandbox. We enabled Full Disk Access for UITests-Runner at Settings -> Privacy & Security -> Full Disk Access but unfortunately still see this alert. Is there any way to permanently remove/hide this alert or remove sandbox for 'UITests-Runner' since we want to run tests on CI and having this alert is not an option? Note: everything works fine on previous versions of macOS. Environment: macOS - 15.1 (24B83) Xcode - Version 16.1 (16B40)
0
1
466
Nov ’24
Couldn't pass IOConnectCallScalarMethod output greater than 16 elements
According to Communicating Between a DriverKit Extension and a Client App we can use IOConnectCallScalarMethod to send/get data to Driver. We use unchecked variation of IOConnectCallScalarMethod to call method in our Driver from Client App. In a Driver's method we set arguments->scalarOutputCount greater than 16. However in a Client app outputCount equal to 16, so we can get only a portion of output. Is 16 limit enforced by IOConnectCallScalarMethod implementation? How we can get more than 16? Should we use IOConnectCallStructMethod instead?
1
0
1.3k
Jul ’22
DriverKit: Check that driver is enabled on iPadOS
Apple Docs mentions that driver should be approved(enabled) in Settings app. I wonder is there any API available to check that driver is not enabled? To my mind, App with driver should have a following flow: Run App Check that driver is(not) enabled Display message(alert) and ask to enable driver in Settings. Optionally: provide shortcut to exact Settings page Unfortunately, it's not obvious how to check that driver is enabled.
3
0
1.4k
Jan ’25