Post

Replies

Boosts

Views

Activity

Adding print to Just changes behaviour of Combine sequence
Code block below produces different results depending on if print is commented or not: import Combine var cancellables = SetAnyCancellable() enum FruitError: Error { case bad } var fruit = "apple" func getFruit() - String { fruit } Just(getFruit) //.print() .map{$0()} .flatMap { value - AnyPublisherString, FruitError in print("in flat map \(value)") if value == "apple" { fruit = "pineapple" return Fail(error: FruitError.bad).eraseToAnyPublisher() } return Just("banana").setFailureType(to: FruitError.self).eraseToAnyPublisher() } .retry(1) .sink(receiveCompletion: { print($0) }, receiveValue: {print($0)}) .store(in: &cancellables) Without print: in flat map apple in flat map apple failure With print: in flat map apple in flat map pineapple banana receive finished finished receive finished Why does print or any other debug operator(breakpoint or handleEvent) change behaviour of sequence? Playground without print - https://developer.apple.com/forums/content/attachment/d8a1d043-191b-41f3-8f0e-72dafa621374 Playground with print - https://developer.apple.com/forums/content/attachment/7c0de4c2-37fb-4136-ae8e-5ed0e77287c5
4
0
1.4k
Mar ’21
testmanagerd constantly requests password to enable UI Automation on macOS Monterey
We updated our CI machine to: macOS Monterey Version 12.0.1 Xcode Version 13.1 (13A1030d) We started to receive UITest failures with following error: Testing failed: MemoryLeaksUITests: MemoryLeaksUITests-Runner (3507) encountered an error (The test runner failed to initialize for UI testing. If you believe this error represents a bug, please attach the result bundle at /Users/dev/Library/Developer/Xcode/DerivedData/MemoryLeaks-dduvihbyiuzwdnawggthtfwdgwks/Logs/Test/Test-MemoryLeaks-2021.11.05_13-43-58-+0300.xcresult. (Underlying Error: Timed out while enabling automation mode.)) The failure disappears if we enable UIAutomation for testmanagerd by providing password However it's not one time action. This permission dialog still appears after some time during a day. We noticed it constantly appears after machine reboot. Unfortunately it blocks us from using our CI machine as test runner. There is no option(checkbox) to permanently enable(provide password) automation in this dialog. Also it's not possible to add it in Settings -> Security & Privacy -> Privacy - Automation. Here is a sample project on GitHub to reproduce the issue. Steps: Reboot machine Run in terminal xcodebuild -target MemoryLeaksUITests -scheme MemoryLeaks test
4
0
4.9k
Mar ’22
DriverKit logs not coming into Сonsole App
We created Driver sample by Xcode template and following macro was added into code: #define Log(fmt, ...) os_log(OS_LOG_DEFAULT, "Driver - " fmt "\n", ##__VA_ARGS__) We used this macro in init and start. For example: bool ForcePlateDriver::init() { Log("init()"); But our logs are not displayed in Console app. Did we miss something? Is anything else is required to have logs for Driver? Our environment: MacOS Monterey - 12.4 (21F79) Xcode - Version 13.4 (13F17a)
5
2
2.8k
Oct ’22
How to do async IO using IOUSBHostPipe?
We followed WWDC Session: System Extensions and DriverKit and recreated a code to do USB device communication via IOUSBHostPipe: struct MyDriver_IVars {     IOUSBHostInterface       *interface;     IOUSBHostPipe            *inPipe;     OSAction                 *ioCompleteCallback;     IOBufferMemoryDescriptor *inData;     uint16_t                  maxPacketSize; }; kern_return_t IMPL(MyDriver, Start) { ...     ivars->maxPacketSize = 64;     ret = ivars->interface->CreateIOBuffer( kIOMemoryDirectionInOut,                                            ivars->maxPacketSize,                                            &ivars->inData);     ret = CreateActionReadComplete(0, &ivars->ioCompleteCallback); ret = ivars->inPipe->AsyncIO(ivars->inData,                                  ivars->maxPacketSize,                                  ivars->ioCompleteCallback,                                  0); ... } Our Driver is started by OS when device is connected. We see that ReadComplete callback is called: void IMPL(MyDriver, ReadComplete) {     Log("ReadComplete() - status - %d; bytes count - %d", status, actualByteCount); } However it's not obvious how to read data received in this callback. I suspect that we should use IOBufferMemoryDescriptor *inData but we didn't find any good example/sample and documentation is poor. Our callback is called only once. It's not clear how to read a series of data from device? Should we create some loop and call inPipe->AsyncIO from callback? Also it would be helpful to see how to pass data to device. I hope we should fill IOBufferMemoryDescriptor *inData.
5
2
1.3k
Jul ’22
.accessibilityElement(children: .contain) produces memory leaks in UITests
We were encourage by Frameworks Engineer reply and Apple's Official Docs and started to use this approach in our App. But next we detected that App has leaked objects when we do Memory Graph Check in UITests. Removing of .accessibilityElement(children: .contain) solves the issue but we still want to use container identifiers in our UITests. Here is a sample project to illustrated and reproduce the issue: https://github.com/yuri-qualtie/MemoryLeaks. All the details and steps are described in Readme We need help with fix for .accessibilityElement(children: .contain) but any workaround is welcomed
6
0
2.8k
Sep ’21
Button.keyboardShortcut(.defaultAction) doesn't properly work on macOS Monterey
In following code example: struct ContentView: View {     @State var text: String = "sample text"     var body: some View {         VStack {             TextField("", text: $text)             Button(action: { print("action performed!") }) {                 Text("Click me")             }             .keyboardShortcut(.defaultAction)         }         .padding(40)     } } .keyboardShortcut(.defaultAction) that is attached to Button perfectly works on macOs Big Sur(11.6) and I see "action performed!" in Xcode console when tap Enter key on keyboard. Unfortunately, same example doesn't work on macOs Monterey(12.0.1) and Xcode 13.1. So nothing happens(I don't see any logs) when I tap Enter key on keyboard. Also I noticed that it happens only when focus is set in TextField. I checked that onSubmit can solve this issue. Unfortunately, I can't use since it's available in macOs 12 or newer but my App has deployment target is macOs 11. So any workarounds are welcomed.
6
1
2.3k
Jul ’23
How to get distribution entitlements for DriverKit on iPadOS?
We got development entitlement for our Driver that we requested here: https://developer.apple.com/contact/request/system-extension/ Next we tested our Driver on test devices and now want to upload build into TestFlight. But it looks like we need distribution version of same entitlements. Where we can request them? BTW, Apple Docs: Requesting Entitlements for DriverKit Development describe only development approach. It would be good to add instructions for Distribution as well.
6
2
1.4k
Nov ’22
Incredible huge .xcresult is generated by Xcode 13.2.1 in case of failure
We use .xcresult files on our CI and recently noticed that size of file significantly increased. So previously we had files ~ 50 MB but now they are ~ 300 MB. After investigation of .xcresult contents we found that it contains macOS Logs - test-session-systemlogs-2022.01.05_13-13-07-+0000 In testmanagerd .log we see in a last line: Moved logarchive from /var/tmp/test-session-systemlogs-2022.01.05_13-13-07-+0000.logarchive to ../Staging/1_Test/Diagnostics/My Mac_4203018E-580F-C1B5-9525-B745CECA79EB/test-session-systemlogs-2022.01.05_13-13-07-+0000.logarchive Issue is reproducible on a new project. Steps: File -> New -> Project Select macOS -> App Enable include test For simplicity disable(comment) all the UITests except ResultSampleUITests::testExample Add XCTAssertTrue(false) after app.launch() Run tests from console and specify path to resultBundlePath xcodebuild -project ResultSample.xcodeproj -scheme ResultSample -resultBundlePath ~/Downloads/2/all-tests -test-timeouts-enabled YES test 7. When tests are finished navigate to resultBundlePath and check size of all-tests.xcresult. It has size 51.6 MB for me. If change XCTAssertTrue(false) to XCTAssertTrue(true) then size of all-tests.xcresult is decreased to 31 KB. Any idea how to disable/delete macOS diagnostic logs or decrease a size of .xcresult
9
3
5.3k
Sep ’22
Launch argument "-AppleLocale en_US" doesn't change measurement system(units) to "US" on MacOs
We used Locale::usesMetricSystem to distinguish between metric and Imperial(US) measurement systems. We set "-AppleLocale en_US" as launch argument for App in UITests but usesMetricSystem still returns true in case user's locale are not equal to "US" in System Preferences - Language and Region - Region. Here is a demo project to illustrate the issue: https://github.com/yuri-qualtie/UseMetricSystemDemo Precondition: Change user region to not US(for example Australia) in System Preferences - Language and Region - Region We expect that code: print(Locale.current.usesMetricSystem) prints false when -AppleLocale en_US is set but actual result is true Probably there is alternative way how to change measurement system via launch arguments or App's settings in Xcode?
16
0
7.2k
Oct ’22