Post

Replies

Boosts

Views

Activity

Reply to Launch Agent service not starting post login
But my problem is why the 'RunAtLoad' function of plist is not working to start my service when an user log in on my test machine? In console logs I could see 'backgroundtaskmanagementd' working on my agent but eventually my service is not started. 2024-03-19 15:48:42.797870+0530 0xaf9 Default 0xa78 164 0 backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: appURL=(null), type=legacy agent, url=file:///Library/LaunchAgents/com.*****.****ui.plist, config={ BTMConfigArguments = ( "/Applications/**** **** ***** Module.app/Contents/MacOS/**** ***** ***** Module" ); BTMConfigBundleIdentifiers = ( ); BTMConfigExecutablePath = "/Applications/***** ***** ****** Module.app/Contents/MacOS/***** ***** ****** Module"; BTMConfigLabel = "com.*****.client.****ui"; } More logs are available in my 1st post.
Mar ’24
Reply to Launch constraints using LightweightCodeRequirements framework
Hi Quinn, Thanks for sharing the result from your setup. Below is the output from my Mac machine: macOS Version: 14.7.2 SDK Version: 14.5 will start launchRequirementData is set (486 bytes) Decoded launchRequirementData: <?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> <key>value</key> <dict> <key>arrayKey</key> <string>$and-array</string> <key>key</key> <string>$and</string> <key>value</key> <array> <dict> <key>key</key> <string>team-identifier</string> <key>value</key> <string>SKMME9E2Y8</string> </dict> </array> </dict> </dict> </plist> did start did finish, status: 0 Program ended with exit code: 0 Does this mean LightweightCodeRequirements framework is not working as expected on all setups? Can this be a bug in the framework? Also noticed that on Macos 15.3 it works fine.. Is there any known issue? import Foundation import LightweightCodeRequirements func getMacOSVersion() -> String { let process = Process() let pipe = Pipe() process.executableURL = URL(fileURLWithPath: "/usr/bin/sw_vers") process.arguments = ["-productVersion"] process.standardOutput = pipe do { try process.run() process.waitUntilExit() let data = pipe.fileHandleForReading.readDataToEndOfFile() if let version = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) { return version } } catch { return "Unknown" } return "Unknown" } func getSDKVersion() -> String { let process = Process() let pipe = Pipe() process.executableURL = URL(fileURLWithPath: "/usr/bin/xcrun") process.arguments = ["--sdk", "macosx", "--show-sdk-version"] process.standardOutput = pipe do { try process.run() process.waitUntilExit() let data = pipe.fileHandleForReading.readDataToEndOfFile() if let version = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) { return version } } catch { return "Unknown" } return "Unknown" } func signedByMyTeamRequirement() throws -> Data { let req = try OnDiskCodeRequirement.allOf { TeamIdentifier("SKMME9E2Y8") } let encoder = PropertyListEncoder() encoder.outputFormat = .xml return try encoder.encode(req) } func printLaunchRequirementData(req: Data) { print("launchRequirementData is set (\(req.count) bytes)") if let plistObject = try? PropertyListSerialization.propertyList(from: req, options: [], format: nil), let plistData = try? PropertyListSerialization.data(fromPropertyList: plistObject, format: .xml, options: 0), let plistString = String(data: plistData, encoding: .utf8) { print("Decoded launchRequirementData:\n\(plistString)") } else { print("[ERROR] Failed to decode launchRequirementData.") } } func main() { let macOSVersion = getMacOSVersion() let sdkVersion = getSDKVersion() print("macOS Version: \(macOSVersion)") print("SDK Version: \(sdkVersion)") do { print("will start") let p = Process() p.executableURL = URL(fileURLWithPath: "/usr/bin/true") p.launchRequirementData = try signedByMyTeamRequirement() if let launchData = p.launchRequirementData { printLaunchRequirementData(req: launchData) } else { print("[ERROR] launchRequirementData is nil.") } try p.run() print("did start") p.waitUntilExit() print("did finish, status: \(p.terminationStatus)") } catch { print("did not start, error: \(error)") } } main()
Feb ’25
Reply to Launch constraints using LightweightCodeRequirements framework
Hi Quinn, I upgrade my MacOS to 15.2 and still the Launch constrains are not working on my setup. If you suggest I will file a bug so that it can be looked by the concern Apple team. I checked on few other setups and it is working fine including on MacOS 14.7.1. I need another help, is there a way we can put Launch constrains based on Authority, eg: Authority=Developer ID Application: Abc LLC (EQHXZ8M8AV) Thanks
Feb ’25