Hi, I am a newcomer in macOS development, and I am struggling to create a package with the XCode command line tools that is installable on other computers. In its minimal version, the package shall install a simple program to usr/local/
:
hello.c
:
#include <stdio.h>
int main(void) {
printf("Hello World\n");
return 0;
}
distribution.plist
:
<installer-gui-script minSpecVersion="1">
<product id="net.world" version="1.0"/>
<title>Hello World</title>
<choices-outline>
<line choice="net.world.hello"/>
</choices-outline>
<choice id="net.world.hello" title="Hello">
<pkg-ref id="net.world.hello">h1.pkg</pkg-ref>
</choice>
</installer-gui-script>
build.sh
:
#!/bin/sh
cc -o hello hello.c
mkdir -p local/bin
cp hello local/bin/
codesign -s - -i net.world.hello local/bin/hello
pkgbuild --identifier net.world.hello \
--root local \
--install-location /usr/local \
h1.pkg
productbuild --distribution distribution.plist --resources . hello.pkg
The build scrips produces a package hello.pkg
. However, when I try to install it, I get
<Debug>: Product archive /Users/foo/hello.pkg trustLevel=100
<Error>: PKInstallRequest: failed to initialize. Error: Error Domain=PKInstallRequestErrorDomain Code=2 "Specifier Description:<PKPackageSpecifier>:
{
URL = "file:///Users/foo/h1.pkg";
identifier = "net.world.hello";
options = 0;
version = 0;
}" UserInfo={NSLocalizedFailureReason=Specifier Description:<PKPackageSpecifier>:
{
URL = "file:///Users/foo/h1.pkg";
identifier = "net.world.hello";
options = 0;
version = 0;
}}
<Debug>: External component packages (1) trustLevel=100 (trust evaluation failed)
<Debug>: -[IFDInstallController(Private) _buildInstallPlanReturningError:]: location = file://localhost
<Debug>: -[IFDInstallController(Private) _buildInstallPlanReturningError:]: file://localhost/Users/foo/h1.pkg
<Error>: Failed to locate package at path /Users/foo/h1.pkg (h1.pkg -- file://localhost/Users/foo/hello.pkg)
<Error>: Install failed: The Installer can’t locate the data it needs to install the software. Check your install media or internet connection and try again, or contact the software manufacturer for assistance.
The package build runs on Github Action (macOS 11/Xcode 13.2).
What is wrong with this setup, and how can I create a distributable package that installs in /usr/local/
?