[Xcode15 Beta] ERROR: Failed to install the app on the device.

I am facing an Issue when trying to install an app using xcrun devicectl device install app command.

Command used

xcrun devicectl device install app /tmp/avinash/Payload/Sample iOS.app --device <deviceid>

Error thrown

code-block15:27:24  Acquired tunnel connection to device.
15:27:24  Enabling developer disk image services.
15:27:24  Acquired usage assertion.

ERROR: Failed to install the app on the device. (com.apple.dt.CoreDeviceError error 3002.)
         NSURL = file:///tmp/avinash/Payload/Sample%20iOS.app/
--------------------------------------------------------------------------------
ERROR: The item at Sample iOS.app is not a valid bundle. (com.apple.dt.CoreDeviceError error 3000.)
         NSURL = file:///tmp/avinash/Payload/Sample%20iOS.app/
         NSLocalizedFailureReason = Failed to get the identifier for the app bundle.

Temporary fix

Rebooting the host machine fixes the issue but it reappears after some time.

Related system log generated during app installation

kernel: (Sandbox) /Library/Developer/PrivateFrameworks/CoreDevice.framework/Versions/A/XPCServices/CoreDeviceService.xpc/Contents/MacOS/CoreDeviceService exhausted sandbox memory capacity; may be leaking extensions

kernel: (Sandbox) Sandbox: CoreDeviceService(8658) deny(1) file-read-data /tmp/avinash/Payload/Sample iOS.app
  1. Another potential temporary solution can be: releasing the sandbox memory. How this can be achieved? How can be sandbox memory cleared?
  2. What can be the permanent solution for this issue?

I tried clearing derivedData folder but didn't help.

I was running into the same issue with several Xcode projects. Luckily, clean new projects would install on my devices just fine, and I could compare the two configurations. I tried adjusting various aspects of the project and targets, e.g. Project Format, Localisation, Identity.

The change that fixed it in the end was to specify "Bundle name" in the Info.plist:

<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>

The issue you are experiencing is a result of a bug in a Core Device component. The bug leads to the system's sandbox memory eventually becoming exhausted, preventing Xcode (and other tools such as devicectl) from being able to install apps and perform other actions involving user-provided files and paths.

However, the good news is that this bug has been fixed as of Xcode 15.1, which is currently in beta. If you have a developer account you can grab it here: https://developer.apple.com/news/releases/

I know some of you don't use beta releases, but in this case you don't actually need to use it. It just needs to be run at least once. Once you download Xcode 15.1, run it once and let it install the additional components when it prompts you. This will update the Core Device components on your system and install newer versions which do not have the bug. You can then go back to using Xcode 15.

Please try this out and let us know through Feedback Assistant if you experience any issues. I promise you that we do read the reports.

@Developer Tools Engineer Thanks for the fix and update on the issue.

I tried using the 15.1 beta 3 xcode and found the Issue resolved (CoreDeviceService memory not getting exhausted after some time of test execution). Though, stepped into another issue now(find in below points).

  • Ran 150-200 UI tests using xcodebuild test-without-building command.
  • Suddenly, UI tests started failing with below error
Error Domain=com.apple.dt.deviceprep Code=-27 "Browsing on the local area network for iPhone, which has previously reported preparation errors" UserInfo={NSUnderlyingError=0x60000bf8e670 {Error Domain=com.apple.dt.CoreDeviceError Code=1000 "The specified device was not found." UserInfo={com.apple.dt.DVTCoreDevice.operationName=connect, NSLocalizedDescription=The specified device was not found., DVTIssueReportingFunctionalityKey=1}}, NSRecoveryAttempter=<_DVTErrorRecoveryHandler: 0x600003068270>, NSLocalizedRecoverySuggestion=Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly., NSLocalizedRecoveryOptions=(
    Cancel
), DVTRecoveryBlockKey=<__NSMallocBlock__: 0x60000a016670>, NSLocalizedDescription=Browsing on the local area network for iPhone, which has previously reported preparation errors}
2023-11-29 13:41:46.643 xcodebuild[21347:1823038]  Run Destination Preflight: Waiting for the destination to become ready.
2023-11-29 13:41:46.644 xcodebuild[21347:1822911] [MT] Run Destination Preflight: Waiting for the destination to become ready.
2023-11-29 13:41:46.652 xcodebuild[21347:1822911] [MT] IDETestOperationsObserverDebug: 108.183 elapsed -- Testing started completed.
2023-11-29 13:41:46.652 xcodebuild[21347:1822911] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2023-11-29 13:41:46.652 xcodebuild[21347:1822911] [MT] IDETestOperationsObserverDebug: 108.183 sec, +108.183 sec -- end
Testing failed:
	BudgetKeeperUITests-Runner (424) encountered an error (Failed to establish communication with the test runner. (Underlying Error: A connection to this device has not been established.))
  • After this issue, app install also started failing with below error message
13:45:38  Enabling developer disk image services.
13:45:38  Acquired usage assertion.

ERROR: Timeout while connecting to remote device. (com.apple.mobiledevice error -402652910.)
         FunctionName = _AMDeviceCreateWithRemoteDeviceWithError
         LineNumber = 325
  • Surprisingly, this issue got resolved in 3-4 minutes automatically but during these 3-4 min all tests failed, all app install failed.

Requesting to look into this new issue and fix in upcoming beta version.

Also, I am interested in knowing the root cause of CoreDeviceService memory exhaust issue and how this was related to app install failure :)

[Xcode15 Beta] ERROR: Failed to install the app on the device.
 
 
Q