Add convenience method to save the entitlements of a bundle to a file as XML
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 11 Sep 2024 13:54:49 +0000 (21:54 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 11 Sep 2024 13:54:49 +0000 (21:54 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
admin/osx/mac-crafter/Sources/Utils/Codesign.swift

index 16da33eb363e068fd717b6337738e02cad79b646..027d99c32cb5e6eb54c4f1ba9dfe42f4fd6350fd 100644 (file)
@@ -56,6 +56,13 @@ func recursivelyCodesign(path: String, identity: String) throws {
     }
 }
 
+func saveCodesignEntitlements(target: String, path: String) throws {
+    let command = "codesign -d --entitlements \(path) --xml \(target)"
+    guard shell(command) == 0 else {
+        throw CodeSigningError.failedToCodeSign("Failed to save entitlements for \(target).")
+    }
+}
+
 func codesignClientAppBundle(
     at clientAppDir: String, withCodeSignIdentity codeSignIdentity: String
 ) throws {