16

How can I create a single installer package for an OS X binary as well as a few configuration and script files?

Final folders should look like this:

https://i.stack.imgur.com/bFDcY.png

Any help would be appreciated. Thanks.

pkamb
  • 33,281
  • 23
  • 160
  • 191
Devesh
  • 193
  • 1
  • 1
  • 8

3 Answers3

18

Installers are great if you want various things to be placed in different spots – app here, documentation there, support files over here, etc. They're also great for providing configurability of the installation experience (optional extras), or hand-holding for an unusual type of installation that the user might not otherwise understand, or extra work (configuration scripts, permissions modifications, authentication, compatibility checking, etc.) that need to run during the installation process. There is nothing wrong with installers, contrary to the answer from @d00dle, although there is also nothing wrong with distributing your app through the App Store, or as a dmg.

For setting up your own installers, I highly recommend a program called Packages (http://s.sudre.free.fr/Software/Packages/about.html). I am in no way connected to it, but I use it to build the installer for an app that I work on. It greatly smoothes the process of making a complex installer, and has an excellent GUI interface.

bhaller
  • 1,803
  • 15
  • 24
  • The problem with Packages, also Iceberg, is we can't add folder, only files, so if we have multiple sub-folders with multiples files.. we need to add folder one by one ! – Saif Jul 01 '18 at 00:46
  • 1
    This is not true. I just added a folder full of files to a Packages build without issue. – Jon Thompson Oct 23 '18 at 19:43
  • 8
    I'd never rely on third party tools when there are buildt-in utilities to do the job in a clean way. On macOS those are `pkgbuild` and `productbuild`. – Bachsau Mar 07 '19 at 00:40
  • Packages is nice. Thanks for the tip! – Ryan Francesconi Mar 27 '19 at 17:42
  • As someone who both develops for and uses macOS, I don't agree with the cavalier attitude towards placing "app here, documentation there..." As a user, installers always annoy me and make me suspicious of what they are doing. Self contained apps is one of the things I love about macOS. Creating an app should be the first default choice, and documentation and support files should be inside the app bundle. Installers should only be used for situations where deeper integration with the OS is a requirement and it is not possible to do with an app. – GrandOpener Apr 01 '21 at 17:19
  • 1
    Well, that's just, like, your opinion, man. – bhaller Apr 20 '21 at 18:09
  • the Packages installer didnt run for me. I got `“Packages.pkg” can’t be opened because Apple cannot check it for malicious software.` – Hugh Perkins Dec 11 '21 at 15:53
  • 1
    @HughPerkins that is an issue with code signing and/or notarization. The package is probably fine, it just isn't trusted by Apple because it isn't signed/notarized. Typically, you can right-click on the package and choose, in the resulting context menu, that you want to open the package, and after warning you, macOS will then allow you to proceed. If you want to actually get rid of the warning, you'll have to delve into signing/notarization, which is a somewhat separate and complex topic, but the documentation for Packages does have some useful things to say about it; beyond that, Google. – bhaller Dec 11 '21 at 19:12
4

There's also macOS Installer Builder, which is a CLI you can use to create an installer wizard for your .pkg: https://github.com/KosalaHerath/macos-installer-builder

Mikeumus
  • 3,570
  • 9
  • 40
  • 65
  • 1
    That was super helpful. The link in the GitHub repository https://medium.com/swlh/the-easiest-way-to-build-macos-installer-for-your-application-34a11dd08744 was awesome. Step by step guide on how to do it. Thanks again! – wildernessfamily Jul 04 '21 at 17:17
-3

macOS does not normally use installers. Applications are packaged in app containers with the extension .app. This container is "executable" but you're also able to dig in and see what is inside. This is also the format distributed through App Store.

You can create .pkg or .dmg "installers" if necessary, however this is clearly not something apple aims to be standard. I would advise to use the .app pattern and any scripts needed should be self contained and executed on first run.

You can use .dmg to distribute your application outside of App Store (this is still fairly normal).

macOS also includes a terminal program called productbuild that builds a product archive for the macOS Installer or the Mac App Store. Enter man productbuild into the Terminal on a Mac for the manual page.

Ky -
  • 30,724
  • 51
  • 192
  • 308
d00dle
  • 1,276
  • 1
  • 20
  • 33
  • 13
    This is the wrong answer. .pkg is the standard installer, and should be used for anything that needs to be more than in the /Applications folder. Packages is a freeware app to build a pkg file. – Jon Thompson Oct 23 '18 at 19:42
  • 4
    This is outright wrong. `.pkg` files are very common for use with big software applications and even though the self contained `.app` files may be viable for small applications, it is *extremely* common for developers to use a `.dmg` to provide a drag-and-drop copy installation for the file. – NBTX Aug 09 '19 at 16:18
  • While this answer isn't answering the question as asked, I have to disagree with the comments that say it is wrong. While .pkg is standard, .app clearly is and should be the default choice. (And it's likely the correct choice for the OP.) Desktop programs should be self contained apps whenever possible. Packages are for things that need greater OS integration or other unusual setup steps and can't be done with a simple app. It's something you do when you have to, not because you choose to. – GrandOpener Apr 01 '21 at 17:28