Post

Replies

Boosts

Views

Activity

Process() object and async operation
I am maintaining a macOS app, a GUI on top of a command line tool. A Process() object is used to kick off the command line tool with arguments. And completion handlers are triggered for post actions when command line tool is completed. My question is: I want to refactor the process to use async and await, and not use completion handlers. func execute(command: String, arguments:[String]) -> async { let task = Process() task.launchPath = command task.arguments = arguments ... do { try task.run() } catch let e { let error = e propogateerror(error: error) } ... } ... and like this in calling the process await execute(..) Combine is used to monitor the ProcessTermination: NotificationCenter.default.publisher( for: Process.didTerminateNotification) .debounce(for: .milliseconds(500), scheduler: DispatchQueue.main) .sink { _ in ..... // Release Combine subscribers self.subscriptons.removeAll() }.store(in: &subscriptons) Using Combine works fine by using completion handlers, but not by refactor to async. What is the best way to refactor the function? I know there is a task.waitUntilExit(), but is this 100% bulletproof? Will it always wait until external task is completed?
2
0
740
Mar ’24
Execute command line tools /usr/bin from a SwiftUI Sandboxed app
For some years I have developed and maintained a SwiftUI based app as GUI ontop of the command line tool rsync. The app is available on HomeBrew and works as expected, included using rsync command line tool from HomeBrew. I have now developed a new GUI, a downscale version of the original app, using SwiftData and using only the default rsync in /usr/bin/rsync. No access to remote servers by ssh-keys, only local attached disk on your Mac. SwiftData is used for storing data about synchronise tasks and log records from run. The app works, but as soon as I enable the App Sandbox, the app does not permit to executed default included command line tool from /usr/bin. The GUI app executes the command line tool by a Swift Process object.
3
0
778
Feb ’24
What is the best way to include compiler directives for an SwiftUI app macOS 12 - macOS14
I have recently ported my SwiftUI GUI app for rsync (https://github.com/rsyncOSX/RsyncOSX) to Swift 5.9 and macOS Sonoma. The port is mostly adapting to the new Observable macro and probably more than 30+ files are changed on the macOS 14 version. The present app for macOS 12 and macOS 13 utilizes @StateObject. My objective is to release one app which includes the new macros for macOS 14, but I don't know what is the best way to include files supporting macOS 12 - macOS 14. I am using the @avaliable test in code for some parts already, but I think I have to include like a view for macOS14 and another view for macOS 12 - 13.. And many of the views (and classes) have equal names.
0
0
387
Jul ’23
Localized SwiftUI macOS app picks the wrong localization
I am developing a SwiftUI based app (https://github.com/rsyncOSX/RsyncUI) which is localized to two languages, German and Norwegian. The development language is English. Running the app on a Norwegian macOS Montery works OK, the app shows the correct localization. Executing the app on an English macOS setup picks the German localization, and not the base localization which is English. And I don't know what causes the app to pick another language than English on a default English macOS setup.... I am experience this on macOS Monterey and Xcode 13, but also on macOS Big Sur and Xcode 12.5.1
2
0
997
Jul ’21