0

I am building an executable in GoLang for MacOs. I need to add version and copyright information to the built file. How do I do this during the go build process or afterwards?

For example the iBooks application has this information enter image description here

P.S. I usually build for Windows only where I use Versioninfo format to add file properties but cannot find something equivalent for MacOs

Roman Kiselenko
  • 43,210
  • 9
  • 91
  • 103
Buzzy
  • 2,905
  • 3
  • 22
  • 31

1 Answers1

3

iBooks is an application bundle, not a single binary like you would build with go. So you would need to find a way of wrapping the go binary in an app bundle in order to get this detail, and if it was applicable to your executable.

If you right click on the iBooks icon and then select "Show Package Contents", then navigate into the Contents folder you will find (among other files+folders) an Info.plist file and a version.plist file which hold the definition of the copyright and version respectively.

Info.plist

...
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2013–2018 Apple Inc. All rights reserved.</string>
...

version.plist

<?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>BuildAliasOf</key>
    <string>iBooks</string>
    <key>BuildVersion</key>
    <string>1</string>
    <key>CFBundleShortVersionString</key>
    <string>1.14</string>
    <key>CFBundleVersion</key>
    <string>1458.15</string>
    <key>ProjectName</key>
    <string>iBooks</string>
    <key>SourceVersion</key>
    <string>1458015000000000</string>
</dict>
</plist>
  • You can embed an Info.plist into a standalone executable by passing `-sectcreate __TEXT __info_plist path/to/file` to the linker. If the compiler is driving the linker (which is common), you'd pass `-Wl,-sectcreate,__TEXT,__info_plist,path/to/file` to the compiler. Also, version info goes in the Info.plist file. I don't think version.plist is used by the system for anything. – Ken Thomases Jun 28 '18 at 12:57