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()