Mac – Creating an installer (.pkg file) from the command line

applicationsinstallmacpackage-managementpkg

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?

Best Answer

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.