Pkgbuild productbuild requires admin privilege during pkg installation

launchpadpermissionpkg

I am trying to build a Mac application using xcode for use in OS version 10.8 and above. I've created the product archive(.pkg file) using pkgbuild and productbuild commands.

My main goal is to create an app that can be installed without requiring admin password and displayed in launchpad for ease of access.

But the problem with my .pkg is that during installation it asks for admin password.

Precheck:

  1. No part of the code works on or requires sudo permission.
  2. No explicit copy commands made to root directories.
  3. The pkg is signed with a valid certificate.

I understand that it is trying to install by default for all users. So I set installation domain using enable_currentUserHome=true in distribution.xml file which installs the app for a particular user. The app is now installed in /Users/username/Applications instead of /Applications. This does not show the app in launchpad but is accessible through spotlight search.

When I try to force the app install-location to /Applications with enable_currentUserHome=true in distribution.xml, it is not asking for any password, but the installation fails saying unable to copy files from source to destination.

Is there any way to script the installation without requiring admin password and also it must be available in the launchpad?

Or is there any alternative package builders that can guarantee the above requirements?

Update: I've seen other similar questions of this sort but those seem to be outdated and applicable for older versions of the OS which had PackageMaker (now deprecated).

Best Answer

I think you have more developer skills like me, in this particular case the SIP could be the reason for this. Try to log in as root.

And it is stupid question: did you enable in System Preferences > Privacy > Allow apps downloads from „anywhere“??

Fastlane is an alternative for building pkg files.