15

I am getting the following error after migrating from one mac to another using time machine.

Could not attach to pid

Ensure "project title" is not already running, and "system username" has permission to debug it.

Screenshot added.

The error occurs only when running the unit tests for (any) Framework project. Running an application on simulator and device works fine.

Running unit tests for an application works, but running it for any framework can't be launched due to this error. I am getting this error even with Alamofire or PromiseKit unit tests.

I tested the solutions suggested on similar questions on Stackoverflow (I deleted derived data, cleaned everything, reinstalled Xcode, restarted the mac ..) nothing solved the issue till now.

I am using Xcode 9.3 and tested this with Xcode 9.4-beta also.

I am running on Mac OS High Sierra - 10.13.4 (17E199)

Any help / suggestion is welcome!

Community
  • 1
  • 1
AmineG
  • 1,908
  • 2
  • 27
  • 43
  • Does this happen when you check out the project from git? – Ryan Apr 18 '18 at 22:08
  • @Ryan yes this happen even if I check out alamofire from GitHub for example – AmineG Apr 18 '18 at 22:10
  • How do you import the 3rd party frameworks into your project? via `cocoapods`? – Ryan Apr 18 '18 at 22:12
  • I am talking about running unit tests for frameworks, and I mentioned Alamofire and PromiseKit as example. These frameworks do not have dependencies, so no need to cocoapods here. Also as I said in my question, running an application using the framework as well as running unit tests for an application that uses the framework are both working. The problem happen only when opening the framework project and trying to run its unit tests – AmineG Apr 18 '18 at 22:19
  • The unit test target is different with the main target or the 3rd party library target. So you need to import them via project setting or `Podfile`(if you are using cocoapods). The question I asked was to clarify how you are importing the frameworks into your test target. – Ryan Apr 18 '18 at 22:23
  • There is no third party library here. Just a framework project with it's unit tests target (generated by xcode). – AmineG Apr 18 '18 at 22:27
  • So you are trying to create a framework which has `Alamofire` and `PromiseKit` as a dependency? And want to add some unit tests for the framework you created? Or you are actually forking the `Alamofire` and adding some tests? – Ryan Apr 18 '18 at 22:33
  • No, my framework have no dependencies. The same issue that I have with my framework happen also with any other framework. PromiseKit and Alamofire are just examples. – AmineG Apr 18 '18 at 22:41
  • I have this too. It's reproducible very easily. New project (cocoa touch framework) - Tick the "Unit Tests" box when creating the project. Once project is created run the unit tests. Boom it fails with the error – Orion Edwards Aug 02 '18 at 10:50
  • Check if this one works https://stackoverflow.com/a/57848546/1753005 – Jayprakash Dubey Nov 12 '19 at 06:16

6 Answers6

12

After opening a bug report to Apple, they suggested me to:

  • Check if my user is an Admin user. It was the case.
  • Check if I have "_developer" group, in the output of groups command. it was the case. Use this command: dscacheutil -q group
  • Check developer mode rights using the command sudo /usr/sbin/DevToolsSecurity -status. The status was unknown for me.
  • Enable developer mode rights if needed, using the command sudo /usr/sbin/DevToolsSecurity -enable. This solved finally my issue!
Orion Edwards
  • 121,657
  • 64
  • 239
  • 328
AmineG
  • 1,908
  • 2
  • 27
  • 43
9

If you have Mojave OS then:

1) Open your target scheme

enter image description here

2) Uncheck this one

enter image description here

3) Select this scheme while testing this target (ex. Testing "TestApiTarget" - select "TestApiTarget" in schemes on tests).

Its temporary solution from bug report

Vlad Pulichev
  • 3,162
  • 2
  • 20
  • 34
4

I was able to resolve this issue by:

  1. adding Single View App target (I named it HostApp)
  2. setting HostApp target as a host application for test target

Setting HostApp as a host application

den
  • 336
  • 2
  • 12
0

You can try some following steps -

  1. Open the keyChain and check the Keychain certificates and delete the existing ones which are expired.
    1. Uncheck the - automatically manage sign in from Xcode project settings.
    2. Delete any derived data
    3. Clean the project by cmd+k
    4. Then Close and Restart the project and Run...

I hope it will work.

Rahul Singha Roy
  • 548
  • 1
  • 3
  • 13
-1

You can do this following steps -

  1. Kill your simulator and then run it again from Xcode.

  2. If you are trying to build too fast after a build has started. Try stopping and running the project again.

  3. This can be a issue with the untrusted certificates in key-chain access, please remove such a type of certificates and re-build again.

Finally, you can do is recheck the Keychain certificates. Delete the exiting ones by right clicking (they'd passed expiration) and unchecked "automatically manage signing" in Targets->General

Hope above steps will solve your problem.

Rashed
  • 2,349
  • 11
  • 26
-1

Haven't seen this exact error, but I've found removing the derived data helps fix some transient errors that pop up after updates etc.

You can find the location of your derived data folder in Xcode.
Open preferences/locations and click the arrow.
Once in derived data you can remove all the folders. FYI after deleting the derived data folder all your projects will need to be rebuilt.

Hope this helps!

Xcode preferences/locations

xivusr
  • 419
  • 5
  • 15