I've seen multiple tutorials in how to create an installer to distribute a MacOS application, but they're all very simple examples (just installing an application and placing it in /Applications).

To do that, they use :

sudo pkgbuild --install-location /Applications --component application-path ./Desktop/installer.pkg

My situation isn't that complex either, but I can't find out how to do it. I want to install an application to /Applications, but I also want my .pkg to place a .dylib in a specific folder.

I've tried doing this :

sudo pkgbuild --install-location /Applications --component myApp.app/ --install-location /destination/for/my/dylib --component myLib.dylib ./myInstaller.pkg

but it says that it doesn't accept my .dylib because it's not a "valid bundle component".

How can I do this?

  • I'm not personally familiar with pkgbuild syntax (hopefully someone will come along who is), but you may want to look at using the gui program s.sudre.free.fr/Software/Packages/about.html instead. It's a tad clunky in some ways, but overall I've found it greatly simplifies the process of creating complex pkg's. Mar 9, 2021 at 2:58
  • Thank you for the suggestion, but I'm looking to automate this process through a bash script, so it needs to be through the command line. Mar 9, 2021 at 14:39

1 Answer 1


I found an alternative, while not the most ideal, it does the job for me. It's using packagesbuild commandline that comes with Packages (http://s.sudre.free.fr/Software/Packages/about.html). It lets you create a .pkg file through the command line, but you need to create a .pkgproj file, which you create with the Packages application.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .