Post

Replies

Boosts

Views

Activity

Daemon needs to get user name
Years ago my daemon was since then using SCDynamicStoreCopyConsoleUser() function and now it longer works. Basically the daemon needs to know the user name of who is using the system. If I restart the daemon,after the login, it gets the user name. I tried run a shell command via my daemon ("id -F") and look likes it still picks the root as user name. So, is there a way to get the current user name using Swift? ProcessInfo.userName fails too
1
0
305
Sep ’24
Application running a daemon, what about uninstalling?
I have a application that is only the UI for a daemon service. The daemon itself is runnning ok, so far. Now when the user moves the App to trash bin, will the daemon also be uninstalled? How does most MacOS software does that behind the scenes? Like, MS Teams, it runs a daeamon but when the user removes the app the daeamon should be also removed. I am using Packages for installing, so I can for example update, but differently from Windows we normally don`t have an uninstall program. I would appreciate any explanation on that, as for my research I was able to find only how to create daemons.
4
0
854
Jan ’24
Using script or even Swift app, how on MacOS could I install an app into the /System/Applications?
So nowadays my MacOS software uses an installer (http://s.sudre.free.fr/Software/Packages/about.html Packages) and it is able to correctly install the application. My client needs to have a quiet installer because he needs to install the app in a large number of computers so using the interactive mode is not good. I am trying to create a script to do that but I am facing the Read-only file system error. Of course my script runs as root. I tried creating a simple Swift code to check, I got the same. So my question: why an installer such Packages can create the folder into the /System/Applications and copy the required files as it runs at the same level of the script and my test program and them don't have the same permission?
1
0
728
Oct ’23
JSONEncoder issue?
I have a simple structure that will fill a list, this is later converted to json string. Once I convert the list to string, like: let encoder = JSONEncoder() let data = try encoder.encode(myList) jsonString = String(data: data, encoding: .utf8)!) It will convert as Json Array, but the issue is that the it can create more than one array into the string, such "[{key: value,key: value,key: value,key: value}] [{key: value,key: value}]" that second pair of array should not to be expected. I've tried a lot of other examples and everything results in same, maybe its a string limitation, and the list itself isn't big. I could generate the json string by myself, of course, however using the encoder should be enough. Any clue?
7
0
754
Jun ’23
Help on how to read files names from a directory
I need to read the files names into the DiagnosticReports directory, I've tried a some examples from StackOverflow, including below, but I simply cant make it to work: // Create a FileManager instance let fileManager = FileManager.default let documentsURL = fileManager.urls(for: .libraryDirectory, in: .userDomainMask)[0] do { let fileUrls = try fileManager.contentsOfDirectory(at:documentsURL, includingPropertiesForKeys: nil) // process files print(fileUrls) } catch { print("Error while enumerating files \(documentsURL.path): \(error.localizedDescription)") } } listDir(dir: "/Library/Logs/DiagnosticReports") That was the most successful one I got, any other simply won't show anything.
3
0
850
May ’23
How to show permissions for Location Services at Privacy & Security menu?
My MacOS software uses the Location Services, previously to Ventura the user could allow the app to use or deny the use of location. Now Ventura won't show up my software name there, so the user can't enable/disable it. My software is a kind of service (main code is terminal) and I have a GUI to setup the parameters. I can't find any topic related to changes with Ventura. Anyone could help me on this?
2
0
1.4k
Dec ’22
Issue with string
Hello! I will show what is going on here with a very simple example: var str: String str = "Test" func test(param: String) { print(param) } What is happening is: running this in my computer it shows: Test running in another Mac it shows: Optional("Test") This is a simple code, but because of that "optional" the real code will give an error because of "Invalid character" I tried wrap with String() String(describing: ) and I can't fix that. Any help on this? Thanks
12
0
1.1k
Dec ’22
Newbie and getting a error with struct data access
Help please!! I have such struct: struct Config { var logging: Bool var isServer: Bool var isVerbose: Bool var isVirtualMachine: Bool   init() {     logging = false     isServer = false     isVerbose = false     isVirtualMachine = false   } } var config = Config.init() The values for config are loaded in the main file. There at the main file can read it all, but here begins my trouble, that I am trying to figure out about a week (actually I found this point as the offender line just today). Somewhere in another file of the project when trying to read a property of that struct it will crash with a trace trap error. The weird is that is happening, so far, only with SOME, not all, Mac OS Monterey versions and I all saw that if Xcode is installed on the Monterey the program will work (but this is not science proof). On my notebook running Mac OS Monterey, without Xcode it works! Other client's computer it will crash, and so on. So, it will run without any errors with some macOS but will crash in others. I really don't know how to fix it or what can be done. This program was running since 2019 and after I need to make some changes my client asked for this is happening. I wasn't in touch with Swift since that time, so I forget and lost something here.
7
0
985
Nov ’22