Attach process failed when trying to run intents extension via Xcode

Issue Summary

Hi all,

I'm working on an Intents Extension for my app, however when I try to run an intent, Xcode pops up the following error:

Could not attach to pid: "965"

attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)

An image of the error:

This only happens when I try debugging the Intent Extension. Running the main app target or another extension target (e.g. notifications) doesn't produce this error.

Build Setup

Here are the details of my build setup:

  • Mac Mini M1
  • Xcode 13
  • Building to iPhone 11 Pro Max, iOS 15.0.2. I've also tried building to my iPad Pro 12.9 w/ iOS 15.1 and hit the same issue.

Things I've tried:

  • Make sure "Debug executable" is unchecked in the scheme
  • I've tried changing the Launch setting to "Automatic" and "Wait for the executable to be launched"
  • I've made sure to run sudo DevToolsSecurity -enable on my mac
  • Rebooted iPhone devices + mac mini
  • Uninstalled / reinstalled the app
  • Deleted derived data
  • Removing / reinstalling the development certs in my keychain --> this actually seemed to work initially, but then the problem came back and now it doesn't work anymore.

Console Logs

I've looked at the console logs while this error occurs to see if it can shed light on the issue. Here are the ones that seemed notable to me.

These logs seem to show that Siri is trying to save / write to a file that it does not have access too. Seems very suspicious

error	11:42:38.341470-0800	kernel	System Policy: assistantd(31) deny(1) file-read-metadata /private/var/mobile/Library/com.apple.siri.inference
error	11:42:38.342204-0800	assistantd	failed to save contact runtime data. error=Error Domain=NSCocoaErrorDomain Code=512 "The file “com.apple.siri.inference” couldn’t be saved in the folder “Library”." UserInfo={NSFilePath=/var/mobile/Library/com.apple.siri.inference, NSUnderlyingError=0x100fb03a0 {Error Domain=NSPOSIXErrorDomain Code=5 "Input/output error"}}
error	11:42:38.342403-0800	assistantd	InferenceError<errorId=crSaveToRunTimeDBFailed file=/Library/Caches/com.apple.xbs/Sources/SiriInference/SiriInference-3100.49.3.1.2/SiriInference/SiriInference/ContactResolver/ContactResolver.swift function=logRunTimeData(runTimeData:config:) line=378 msg=>
error	11:42:38.465702-0800	kernel	1 duplicate report for System Policy: assistantd(31) deny(1) file-read-metadata /private/var/mobile/Library/com.apple.siri.inference

Looking for "debugserver" entries, like the error suggests, shows these logs:

default	11:42:44.814362-0800	debugserver	error: [LaunchAttach] MachTask::TaskPortForProcessID task_for_pid(965) failed: ::task_for_pid ( target_tport = 0x0203, pid = 965, &task ) => err = 0x00000005 ((os/kern) failure)
default	11:42:44.814476-0800	debugserver	10 +0.011525 sec [03c6/0103]: error: ::task_for_pid ( target_tport = 0x0203, pid = 965, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0203, pid = 965, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005)
default	11:42:44.825704-0800	debugserver	error: MachTask::StartExceptionThread (): task invalid, exception thread start failed.
default	11:42:44.825918-0800	debugserver	error: [LaunchAttach] END (966) MachProcess::AttachForDebug failed to start exception thread attaching to pid 965: unable to start the exception thread
default	11:42:44.826025-0800	debugserver	error: Attach failed
default	11:42:44.828923-0800	debugserver	error: Attach failed: "Not allowed to attach to process.  Look in the console messages (Console.app), near the debugserver entries, when the attach failed.  The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.".

I've also attached the full details of the error below via a text file if it helps.

Any help with this issue would be great, and I'm happy to provide more information if needed. Thanks in advance!

Just wanted to add some additional information... I stumbled across this apple forum post, which shows similar Console.app logs. I verified that these things were true in my app:

  • CODE_SIGN_INJECT_BASE_ENTITLEMENTS == YES
  • DEPLOYMENT_POSTPROCESSING == NO
  • I checked the entitlements on my app and verified that the get-task-allow is present:
	<key>get-task-allow</key>
	<true/>

I have same issue now. Did you solve this? If you did, please let me know your solution.

I am also facing the same issue with XCode 14, MacBook Pro, Monterey OS, Intel processor.

Getting below error:

error: attach failed: attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)

Did you find any way to resolve this, I am stuck as I am not able to debug my app.

The solution I found was to make sure the following build settings were configured correctly:

  1. in Deployment section, DEPLOYMENT_POSTPROCESSING = NO for debug, YES for release.
  2. in Sign section, CODE_SIGN_INJECT_BASE_ENTITLEMENTS = YES for debug, NO for release.

After setting these correctly (Deployment Postprocessing was somehow set to YES for both, I have no idea how that happened), I was able to debug again.

My solution was to change wrongly set Provisioning profile under Debug section for tvOS target to a development profile.

I faced similar issue, but with main tvOS app target. XCode 15, Sonoma 14.0 I didn't touch tv target for a while, updated XCode few times and then found that I can't debug on apple tv device anymore. Message was the same as posted here. After some failed attempts to fix it by changing build settings, I found that my signing profiles were somehow messed up and InHouse profile was selected in Provisioning profile under Debug section. I changed this profile back to my development profile and suddenly it all worked. Weird thing that wrong profile was never mentioned in any error message.

Just in case my build settings which were mentioned in this post are both set to default values:

  • CODE_SIGN_INJECT_BASE_ENTITLEMENTS - YES for both (default value)
  • DEPLOYMENT_POSTPROCESSING - NO for both (default value)

FWIW, I got a similar error message under very different circumstances (debugging the Alive2 translation library called from opt in a fork of LLVM on my Mac). Both entitlements are set correctly; a clean build before each run worked around the problem. Merely touching one of the source files, so that the Run button recompiles, also seems to work around it.

Attach process failed when trying to run intents extension via Xcode
 
 
Q