Error when using pkgutil to flatten an application bundle into a flat package

applicationscommand lineopen sourcepkgxcode

I have an application bundle that I need to convert to a flattened package. In my case, the application is a simple bash script that has been bundled into an application using Platypus. To flatten the bundle, I used the following command on a machine running macOS 10.15.3…

pkgutil --flatten /path/to/application_bundle /path/to/flattened_package

When then attempting to run the flattened package, I receive the error, "You can't open the application because it is not supported on the type of Mac." However, the bundled app runs without any issue. Any ideas on how to convert a bundled app to a flattened app that will run?

Best Answer

pkgutil is the wrong tool for this. Use pkgbuild instead. The syntax is...

pkgbuild --root /path/to/application_bundle.app --identifier com.company.application --version 1.0 --install-location /Applications /path/to/flattened_package.pkg

Some MDM's require a product archive instead of a flattened package. If that is the case, you can then use productbuild to create a product archive. The syntax for that is...

productbuild --version 1.0 --package /path/to/flattened_package.pkg /path/to/archive.pkg