diff --git a/admin/osx/mac-crafter/Sources/Utils/Codesign.swift b/admin/osx/mac-crafter/Sources/Utils/Codesign.swift index be7eb586d6da9..b511f0a443e27 100644 --- a/admin/osx/mac-crafter/Sources/Utils/Codesign.swift +++ b/admin/osx/mac-crafter/Sources/Utils/Codesign.swift @@ -21,6 +21,7 @@ enum CodeSigningError: Error { } enum AppBundleSigningError: Error { + case doesNotExist(String) case couldNotEnumerate(String) } @@ -64,6 +65,10 @@ func recursivelyCodesign( skip: [String] = [] ) throws { let fm = FileManager.default + guard fm.fileExists(atPath: path) else { + throw AppBundleSigningError.doesNotExist("Item at \(path) does not exist.") + } + guard let pathEnumerator = fm.enumerator(atPath: path) else { throw AppBundleSigningError.couldNotEnumerate( "Failed to enumerate directory at \(path)." @@ -118,14 +123,21 @@ func codesignClientAppBundle( // Multiple components of the app will now have the get-task-allow entitlements. // We need to strip these out manually. - print("Code-signing Sparkle autoupdater app (without entitlements)...") let sparkleFrameworkPath = "\(frameworksPath)/Sparkle.framework" - try recursivelyCodesign(path: "\(sparkleFrameworkPath)/Resources/Autoupdate.app", - identity: codeSignIdentity, - options: "--timestamp --force --verbose=4 --options runtime --deep") + if FileManager.default.fileExists(atPath: "\(sparkleFrameworkPath)/Resources/Autoupdate.app") { + print("Code-signing Sparkle autoupdater app (without entitlements)...") - print("Re-codesigning Sparkle library...") - try codesign(identity: codeSignIdentity, path: "\(sparkleFrameworkPath)/Sparkle") + try recursivelyCodesign( + path: "\(sparkleFrameworkPath)/Resources/Autoupdate.app", + identity: codeSignIdentity, + options: "--timestamp --force --verbose=4 --options runtime --deep" + ) + + print("Re-codesigning Sparkle library...") + try codesign(identity: codeSignIdentity, path: "\(sparkleFrameworkPath)/Sparkle") + } else { + print("Build does not have Sparkle, skipping.") + } print("Code-signing app extensions (removing get-task-allow entitlements)...") let fm = FileManager.default