Not able to install pkg file using "InstallApplication" command on macOS

We developing to distribute pkg files using "InstallApplication" MDM command for macOS, for iOS it works fine using ipa.


1. So first we created test app (HelloWorld) and notarized it.

psls-Mac-mini:notarised psl$ spctl -a -v HelloWorld.app
HelloWorld.app: accepted
source=Notarized Developer ID


2. Created pkg from app file using productbuild and signed it using productsign and used "Developer ID Installation: ******" certificate for same.


3. Notarised pkg file as well using xcrun altool validation performed for same:

psls-Mac-mini:pkg psl$ spctl -a -v --type install HelloWorldS.pkg
HelloWorldS.pkg: accepted
source=Notarized Developer ID


4. Then stapled using pkg file using "xcrun stapler staple HelloWorld.pkg", the validate action worked for same.


5. The same app is distributed to device "InstallApplication" commmand to macOS 10.14.6 (Mojave) device which returns Acknowledge and triggers Fetch Manifest for same application:


6. Log from macOS endpoint for same:

default 18:25:53.678194 +0530 mdmclient Processing server request: InstallApplication  for: 
default 18:25:53.679189 +0530 mdmclient Scheduled InstallApplication from: HTTPS://*****************:443/mdm/ios/menifest/8D13AD71-FB64-5751-B666-DFC03BEFB61D/41d8289a-d4a5-49c0-835e-fbd46e615897


7. The server responds with below manifest for request:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>items</key>

<array>

<dict>

<key>assets</key>

<array>

<dict>

<key>kind</key> <string>software-package</string>

<key>md5-size</key> <integer>3328671</integer>

<key>md5s</key> <array> <string>57fe16ec2cfaa7d38409ecf784782a44</string> </array>

<key>url</key> <string>HTTPS://**************:443/RESOURCE/MOBILE/FILE/E10035BB7641</string>

</dict>

</array>

<key>metadata</key>

<dict>

<key>bundle-identifier</key> <string>com.*******.HelloWorld</string>

<key>bundle-version</key> <string>1.0</string>

<key>kind</key> <string>software</string>

<key>sizeInBytes</key><integer>3328671</integer>

<key>title</key> <string>HelloWorld</string> <key>items</key>

<array>

<dict>

<key>bundle-identifier</key><string>com.*********.HelloWorld</string>

<key>bundle-version</key><string>1.0</string>

</dict>

</array>

</dict>

</dict>

</array>

</dict>

</plist>


8. The server responds as Acknowledged and starts with fetching pkg file at macOS endpoint. log from endpoint for same:

default 18:26:45.462058 +0530 storeassetd MDM Starting download 
default 18:26:45.465573 +0530 storeassetd SoftwareMap: No app was found with bundle ID com.accelerite.HelloWorld to upgrade to 1.0
default 18:26:45.466082 +0530 storedownloadd DownloadManifest: removePurgeablePath: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13
default 18:26:45.467811 +0530 storeassetd SoftwareMap: No app was found with bundle ID com.accelerite.HelloWorld to upgrade to 1.0
default 18:26:45.471102 +0530 storeassetd SoftwareMap: No app was found with bundle ID com.accelerite.HelloWorld to upgrade to 1.0
default 18:26:45.471554 +0530 storedownloadd DownloadOperation: Warning, unable to check disk space recovery requirements for com.accelerite.HelloWorld (13) because no locally cached preflight was found
default 18:26:45.472434 +0530 storeassetd SoftwareMap: No app was found with bundle ID com.accelerite.HelloWorld to upgrade to 1.0
default 18:26:45.500527 +0530 storeassetd SoftwareMap: No app was found with bundle ID com.accelerite.HelloWorld to upgrade to 1.0
default 18:26:45.500690 +0530 storedownloadd sending status (HelloWorld): 0.000000% (0.000000)
default 18:26:45.501726 +0530 storedownloadd : Initializing MD5 context
default 18:26:45.502170 +0530 storedownloadd ISStoreURLOperation: Starting URL operation with url=HTTPS://***************:443/RESOURCE/MOBILE/FILE/E10035BB7641 / bagKey=(null)
default 18:26:45.502249 +0530 storedownloadd -[ISStoreURLOperation _runURLOperation]: _addStandardQueryParametersForURL: HTTPS://***************:443/RESOURCE/MOBILE/FILE/E10035BB7641
default 18:26:45.504556 +0530 commerced Task .<95> resuming, QOS(0x11)
default 18:26:45.504982 +0530 commerced Task .<95> {strength 0, tls 4, ct 0, sub 0, sig 1, ciphers 0, bundle 1, builtin 0}


9. However it starts download operation and returns below error from storeaccountd process:

default 18:26:45.707509 +0530 storedownloadd : Opening file /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641 returning file descriptor 3 (0 streamed)
error 18:26:45.708886 +0530 storeaccountd "Remote account store returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.accountsd.accountmanager was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.accountsd.accountmanager was invalidated.}"
error 18:26:45.708938 +0530 storeaccountd [AOSAccounts] : [-[ACAccountStore(iCloudAccount) icaAppleAccounts]] : icaAppleAccountType returned no account type
default 18:26:45.710063 +0530 storedownloadd Task <83C34FFA-7387-496D-80FA-DF92C3ADEE61>.<0> {strength 0, tls 4, ct 0, sub 0, sig 1, ciphers 0, bundle 1, builtin 0}

10. However downloading gets still 80% and after that it throws multiple errors as below:

default 18:26:45.795202 +0530 storedownloadd AssetDownloadOperation: Subtracted 0 already-downloaded bytes from required space (now requires 3328671 bytes)
default 18:26:45.795747 +0530 storedownloadd sending status (HelloWorld): 0.000000% (-1.000000)
default 18:26:46.078093 +0530 storedownloadd Task <83C34FFA-7387-496D-80FA-DF92C3ADEE61>.<0> response ended
default 18:26:46.078201 +0530 storedownloadd Task <83C34FFA-7387-496D-80FA-DF92C3ADEE61>.<0> done using Connection 13
default 18:26:46.079237 +0530 storedownloadd sending status (HelloWorld): 80.645162% (8.000000)
default 18:26:46.079451 +0530 storedownloadd sending status (HelloWorld): 80.645162% (8.000000)
error 18:26:46.080143 +0530 storedownloadd NSURLConnection finished with error - code -1100
error 18:26:46.080766 +0530 storedownloadd NSURLConnection finished with error - code -1100
error 18:26:46.081441 +0530 storedownloadd NSURLConnection finished with error - code -1100
error 18:26:46.082030 +0530 storedownloadd NSURLConnection finished with error - code -1100
default 18:26:46.082217 +0530 storedownloadd *** Assertion failure in -[SoftwareInstallOperation _startInstall], /BuildRoot/Library/Caches/com.apple.xbs/Sources/Commerce/Commerce-708.5/CommerceKit/iTunes Protocol/Built Into App/SoftwareInstallOperation.m:303
default 18:26:46.082638 +0530 storedownloadd error Error Domain=NSURLErrorDomain Code=-1100 "The installation could not be started." UserInfo={NSLocalizedDescription=The installation could not be started., NSUnderlyingError=0x7fbe94ecc750 {Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo={NSUnderlyingError=0x7fbe94ca73e0 {Error Domain=kCFErrorDomainCFNetwork Code=-1100 "The requested URL was not found on this server." UserInfo={NSErrorFailingURLStringKey=file:///var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641/index.product, NSLocalizedDescription=The requested URL was not found on this server., NSErrorFailingURLKey=file:///var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641/index.product}}, NSErrorFailingURLStringKey=file:///var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641/index.product, NSErrorFailingURLKey=file:///var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641/inde
default 18:26:46.082823 +0530 storedownloadd underlyingError Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo={NSUnderlyingError=0x7fbe94ca73e0 {Error Domain=kCFErrorDomainCFNetwork Code=-1100 "The requested URL was not found on this server." UserInfo={NSErrorFailingURLStringKey


11. At the end it gives below error with "MDM Error downloading ...." and does nothing.

default 18:26:46.084747 +0530 storedownloadd DownloadOperation: ***** NSURLErrorDomain -1100 *****
default 18:26:46.084826 +0530 storedownloadd DownloadOperation: Request: { URL: HTTPS://BHD025132.persistent.co.in:443/RESOURCE/MOBILE/FILE/E10035BB7641 }
default 18:26:46.084984 +0530 storedownloadd DownloadOperation: Response: { URL: https://bhd025132.persistent.co.in:443/RESOURCE/MOBILE/FILE/E10035BB7641 } { Status Code: 200, Headers {
    Connection =     (
        "Keep-Alive"
    );
    "Content-Disposition" =     (
        "filename=RESOURCE.MOBILE.FILE.E10035BB7641"
    );
    "Content-Length" =     (
        3328671
    );
    "Content-Type" =     (
        "application/octet-stream"
    );
    Date =     (
        "Fri, 25 Oct 2019 12:56:45 GMT"
    );
    "Keep-Alive" =     (
        "timeout=10, max=1000"
    );
    Pragma =     (
        "No-cache"
    );
    Server =     (
        "Apache/2.2.31 (Win32) mod_ssl/2.2.31 OpenSSL/1.0.2d DAV/2 mod_jk/1.2.31 mod_auth_tkt/2.0.0rc3"
    );
} }
default 18:26:46.085050 +0530 storedownloadd DownloadOperation: PeerAddress:10.11.92.171
default 18:26:46.085113 +0530 storedownloadd DownloadOperation: Asset subtype:3
default 18:26:46.085257 +0530 storedownloadd DownloadOperation: File exists at path:/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641
default 18:26:46.092105 +0530 storedownloadd DownloadOperation: Download folder is backed up at /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13.NSURLErrorDomain.1100
default 18:26:46.092169 +0530 storedownloadd DownloadOperation: **********************************
default 18:26:46.094247 +0530 storeassetd SoftwareMap: No app was found with bundle ID com.accelerite.HelloWorld to upgrade to 1.0
default 18:26:46.095406 +0530 storeassetd MDM Error downloading  - Error Domain=NSURLErrorDomain Code=-1100 "The installation could not be started." UserInfo={NSLocalizedDescription=The installation could not be started., NSUnderlyingError=0x7fe88ed38900 {Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo={NSErrorFailingURLKey=file:///var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641/index.product, NSLocalizedDescription=The requested URL was not found on this server., NSErrorFailingURLStringKey=file:///var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641/index.product}}}
default 18:26:46.095488 +0530 storedownloadd startLogging: Client starts logging...
default 18:26:46.095488 +0530 storeassetd MDM Finished download  - 2
default 18:26:46.095715 +0530 storedownloadd DownloadErrorHandler: No longer displaying error dialog for failed download: Error Domain=NSURLErrorDomain Code=-1100 "The installation could not be started." UserInfo={NSLocalizedDescription=The installation could not be started., NSUnderlyingError=0x7fbe94ecc750 {Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo={NSUnderlyingError=0x7fbe94ca73e0 {Error Domain=kCFErrorDomainCFNetwork Code=-1100 "The requested URL was not found on this server." UserInfo={NSErrorFailingURLStringKey=file:///var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641/index.product, NSLocalizedDescription=The requested URL was not found on this server., NSErrorFailingURLKey=file:///var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641/index.product}}, NSErrorFailingURLStringKey=file:///var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/com.apple.appstore/13/E10035BB7641/index.product, NSErrorFailingURLKey=file:///var/folder<…>
default 18:26:46.096582 +0530 rtcreportingd listener: Accepting new XPC connection  as it has proper entitlement, 0(0) connections.


12. There is nothing in system.log and /var/log/install.log file regarding the same.


Is there i am doing wrong here?

How to solve these errors and get pkg installed on macOS endpoint?

Not able to install pkg file using "InstallApplication" command on macOS
 
 
Q