Here’s the script I built to sign a built 4D app.  The xattr command will strip 
all resource forks, so if your app depends on those it won’t run after being 
signed. And you can’t sign the app if it contains resource forks. It also runs 
a couple code signing verification commands after signing, and then zips the 
signed app with the versioned app name specified in CFBundleShortVersionString.

You just have to set your built app name and the developer ID info in the 
variables at the top (appPath, devID).  If you aren’t setting 
CFBundleShortVersionString you’ll need to change the file zipping portion.

If you create this script as something like sign_myapp.command, then you can 
just double-click the file and it will open Terminal and run the script.


#!/bin/bash

cd "${BASH_SOURCE%/*}" || exit
echo "current directory: `pwd`"

devID="Developer ID Application: James Crate (ABCDEFGH)"
appPath="./MyApp.app" # path to built application

if [[ -d $appPath ]]
then
  echo "signing $appPath"
  # clean up by removing file system extended attributes
  xattr -cr "$appPath"
  
  # sign application with developer signature
  codesign --force --deep --verbose --sign "$devID" "$appPath"
  
  # check code-signing
  echo "checking signing"
  spctl -av "$appPath"
  codesign --verify -v "$appPath"
  
  # zip with versioned name
  versionedName=$(/usr/libexec/PlistBuddy "${appPath}/Contents/Info.plist" -c 
'Print CFBundleShortVersionString')
  zipName="./${versionedName}.app.zip"
  echo "zipping to ${zipName}"
  rm "$zipName"
  ditto -c -k --sequesterRsrc --keepParent "$appPath" "$zipName"
  # ditto is what Finder uses for "Compress <file>"
fi




> On Sep 18, 2018, at 4:28 PM, Wayne Stewart via 4D_Tech <[email protected]> 
> wrote:
> 
> Jody,
> 
> This is stolen from someone else (but I don't recall who)
> 
> In Xcode go to prefs
> choose accounts and add your developer account
> click manage certificates
> add a Mac development certificate
> 
> Go to Keychain access
> Look for the certificate named Mac Developer:
> 
> Build your app with 4D (ignore their signing option on the last tab).
> 
> Open the terminal and paste the following in:
> 
> xattr -cr /Users/waynestewart/Documents/4D/4Vet/v17/4vet_Build/Final\
> Application/4vet.app
> codesign -s "Mac Developer: Wayne Stewart (JCGW7WMCVG)" -fvvvv
> /Users/waynestewart/Documents/4D/4Vet/v17/4vet_Build/Final\
> Application/4vet.app --deep
> 
> It might work better if you put your own directory structure,
> application name, and certificate details though.
> 
> If you have three apps to sign you can just copy and paste all six
> lines in at on go.  The terminal will run them sequentially.
> 
> Regards,
> 
> Wayne
> 
> 
> On Wed, 19 Sep 2018 at 09:10, Jody Bevan via 4D_Tech
> <[email protected]> wrote:
>> 
>> I found out a new client upgraded their Macs to a later version of the OS 
>> (High Sierra).
>> 
>> Of course the MacOS app I sent them needs to get signed with an Apple 
>> Certificate.
>> 
>> I researched the 4D KnowledgeBase, read the tech note on doing it and it 
>> seemed easy to use.
>> I downloaded XCode from Apple.
>> Built my Standalone application.
>> 
>> Launched XCode - yike! the interface is very much different. So no following 
>> the step by step instructions like I thought I would be able to do.
>> 
>> Does anyone have step by step instructions for signing a built app with this 
>> version of XCode, or one similar to it they are willing to share?
>> 
>> Otherwise I will be digging into the XCode documentation (where ever that 
>> is) and trying to make sense of what I need to do.
>> 
>> Thanks for your time…
>> 
>> Jody
>> **********************************************************************
>> 4D Internet Users Group (4D iNUG)
>> Archive:  http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:[email protected]
>> **********************************************************************
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to