Post

Replies

Boosts

Views

Activity

Reply to lauchdaemon does not (always) work automatically?
Now I got it working. I use a check at start of my application with following code: if !NetworkCheck().waitForNetwork() {     print("Error: No network available!")     exit(exitCodes.NoNetwork.rawValue) } and this is my NetworkCheck class: import Foundation import Network class NetworkCheck {    private let networkMonitor : NWPathMonitor    init() {       self.networkMonitor = NWPathMonitor(requiredInterfaceType: .wiredEthernet)       self.networkMonitor.start(queue: .global())    }    func waitForNetwork(networkTimeout : Double = 30.0) -> Bool {        let networkLookupStart = Date.now        var isConected         = false        while abs(networkLookupStart.timeIntervalSinceNow) <= networkTimeout {            networkMonitor.pathUpdateHandler = { path in                if path.status == .satisfied {                    isConected = true                }            }            if isConected {                break            }            sleep(1)        }        return isConected    }    deinit {        networkMonitor.cancel()    } }
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’22
Reply to lauchdaemon does not (always) work automatically?
The networking stack on the Mac should work independently of whether a user is logged in. I think so, too but I have no clue why it works always when called manually vs. automatically. It looks like you’re using SwiftNIO for your networking. Are you use Network framework under the covers? That is, are you using NIO Transport Services? Yes. I use SwiftNIO 2.35.0 for my Mailer class which is based on SwiftSMTP. But even when there is a SwiftNIO issue the shell call using sshfs to mount a remote volume should work still work… I wonder if there is a security issue. The deamon process is called as admin user <key>UserName</key> <string>admin</string> <key>GroupName</key> <string>admin</string> and this works as expected. I checked this via ProcessInfo().userName debug output. Edit: AFAIK I don't use NIOTransportServices although the package is included in projects package list. A source search for NIOTransportServices gave no hit.
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’22
Reply to lauchdaemon does not (always) work automatically?
StartCalendarInterval like this (for the other days the same): <key>StartCalendarInterval</key> <array> <dict> <key>Weekday</key> <integer>0</integer> <key>Hour</key> <integer>5</integer> <key>Minute</key> <integer>0</integer> </dict> Edit: The job is started properly but the log shows the errors above. I assume there is a networking issue in case no user is logged in (GUI or via ssh in Terminal).
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’22
Reply to Xcode error on M1 Mac: Could not find module … for target 'x86_64-apple-macos'
I could solve this issue. As stated at https://forums.swift.org/t/xcode-12-2-spm-swift-nio-fails-to-build-for-apple-silicon-arm64/42197/22 I had the same issue & realized I was building for "My Mac", and not "Any Mac".. that fixed it & built the packages for both. (Top left of the center portion of the Xcode main screen.. where you pick your scheme) So building for "Any Mac (Apple Silicon, Intel)" works.
Dec ’21
Reply to lauchdaemon does not (always) work automatically?
Now I got it working. I use a check at start of my application with following code: if !NetworkCheck().waitForNetwork() {     print("Error: No network available!")     exit(exitCodes.NoNetwork.rawValue) } and this is my NetworkCheck class: import Foundation import Network class NetworkCheck {    private let networkMonitor : NWPathMonitor    init() {       self.networkMonitor = NWPathMonitor(requiredInterfaceType: .wiredEthernet)       self.networkMonitor.start(queue: .global())    }    func waitForNetwork(networkTimeout : Double = 30.0) -> Bool {        let networkLookupStart = Date.now        var isConected         = false        while abs(networkLookupStart.timeIntervalSinceNow) <= networkTimeout {            networkMonitor.pathUpdateHandler = { path in                if path.status == .satisfied {                    isConected = true                }            }            if isConected {                break            }            sleep(1)        }        return isConected    }    deinit {        networkMonitor.cancel()    } }
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to lauchdaemon does not (always) work automatically?
Many thanks for your help. Just a few minutes ago I thought the same because Remote Desktop and it showed me sleeping for the server… As a quick solution I added a launch daemon plist which calls caffeinate to prevent sleeping. I'm eager so see if the backup does run tonight and I will post the result tomorrow.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to lauchdaemon does not (always) work automatically?
The networking stack on the Mac should work independently of whether a user is logged in. I think so, too but I have no clue why it works always when called manually vs. automatically. It looks like you’re using SwiftNIO for your networking. Are you use Network framework under the covers? That is, are you using NIO Transport Services? Yes. I use SwiftNIO 2.35.0 for my Mailer class which is based on SwiftSMTP. But even when there is a SwiftNIO issue the shell call using sshfs to mount a remote volume should work still work… I wonder if there is a security issue. The deamon process is called as admin user <key>UserName</key> <string>admin</string> <key>GroupName</key> <string>admin</string> and this works as expected. I checked this via ProcessInfo().userName debug output. Edit: AFAIK I don't use NIOTransportServices although the package is included in projects package list. A source search for NIOTransportServices gave no hit.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to lauchdaemon does not (always) work automatically?
StartCalendarInterval like this (for the other days the same): <key>StartCalendarInterval</key> <array> <dict> <key>Weekday</key> <integer>0</integer> <key>Hour</key> <integer>5</integer> <key>Minute</key> <integer>0</integer> </dict> Edit: The job is started properly but the log shows the errors above. I assume there is a networking issue in case no user is logged in (GUI or via ssh in Terminal).
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to Xcode error on M1 Mac: Could not find module … for target 'x86_64-apple-macos'
I could solve this issue. As stated at https://forums.swift.org/t/xcode-12-2-spm-swift-nio-fails-to-build-for-apple-silicon-arm64/42197/22 I had the same issue & realized I was building for "My Mac", and not "Any Mac".. that fixed it & built the packages for both. (Top left of the center portion of the Xcode main screen.. where you pick your scheme) So building for "Any Mac (Apple Silicon, Intel)" works.
Replies
Boosts
Views
Activity
Dec ’21