Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Current version of codesigner script I'm trying to use to sign Electron apps for use on OS X (not MAS).
# Invoke this script with a relative `.app` path
# EX:
# codesign.sh "dist/osx/MyApp-darwin-x64/MyApp.app"
# I had better luck using the iPhoneOS codesign_allocate
export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate"
#export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate"
# Next two are specified in Apple docs:
# export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"
# export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate"
# However, neither worked, and gave error:
# /Users/JoshBavari/Development/ionic-gui/dist/osx/MyApp-darwin-x64/MyApp.app/Contents/Frameworks/Electron Framework.framework/Electron Framework: cannot find code object on disk
#Run the following to get a list of certs
# security find-identity
app="$PWD/$1"
identity="Developer ID Application: [My dev ID goes here]"
echo "### signing frameworks"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/Electron Framework.framework/Electron Framework"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/Electron Framework.framework/Versions/A"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/Electron Framework.framework/Versions/Current/Electron Framework"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/FilterIt Helper EH.app/Contents/MacOS/FilterIt Helper EH"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/FilterIt Helper NP.app/Contents/MacOS/FilterIt Helper NP"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/FilterIt Helper NP.app/Contents/MacOS/FilterIt Helper NP"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/FilterIt Helper.app/Contents/MacOS/FilterIt Helper"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/Mantle.framework/Mantle"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/Mantle.framework/Versions/A"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/ReactiveCocoa.framework/ReactiveCocoa"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/ReactiveCocoa.framework/Versions/A"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/Squirrel.framework/Squirrel"
codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Frameworks/Squirrel.framework/Versions/A"
#codesign --deep --force --verify --verbose --sign "$identity" "$app/Contents/Resources/app/js/main/phantom-resources/phantomjsosx"
echo "### signing app"
codesign --deep --force --verify --verbose --sign "$identity" "$app"
echo "### Zipping app"
ditto -c -k --sequesterRsrc --keepParent "$app" "$app.zip"
echo "### verifying signature",
codesign -vvvv -d "$app"
sudo spctl -a -vvvv "$app"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment