71

I'm getting the error LLVM Profile Error: Failed to write file "default.profraw": Permission denied after running unit tests in Xcode. I don't know where Xcode is trying to write this file to.

What folder should I grant permissions for?

Cloud9999Strife
  • 3,102
  • 3
  • 30
  • 43

6 Answers6

21

Had this warning when I forgot to enable code coverage:

enter image description here

kasyanov-ms
  • 431
  • 4
  • 12
  • 1
    This fixed it for me too. Should be marked as the correct answer. – Ben Thomas Feb 08 '18 at 09:50
  • 1
    For me, it didn't fix the issue. What is worse, this "warning" appears when the app goes into the background and it detaches the debugger. – Nat Nov 22 '18 at 08:11
  • 1
    didn't fix the issue, also this is option has been moved from that screen already – Chief Madog Feb 24 '19 at 09:27
  • This worked for me, although Xcode has changed since this screenshot was taken. @muhasturk answer, below (which was inexplicably downvoted twice) shows the correct screenshot, as of May 2019. – Gene Loparco May 06 '19 at 21:09
  • Disabling and enabling it again did the trick for me. Seems like something went wrong when merging. + clean + restart of Xcode – palme May 24 '19 at 14:38
11

Xcode 10+

Enable Code Coverage for Test scheme.

enter image description here

muhasturk
  • 2,534
  • 20
  • 16
2

Cleaning my build folder eliminated the error for me. (Option-Shift-Command K.) I'm using Xcode Version 9.2 (9C40b). The error started when I added a set of images to my Assets.xcassets. After a full clean the error is gone.

John Pavley
  • 5,366
  • 2
  • 14
  • 16
2

Try setting CLANG_ENABLE_CODE_COVERAGE = NO in your build settings for the target being tested and the tests themselves.

Edit: Please see the answer by @kasyanov-ms.

Coder-256
  • 5,212
  • 2
  • 23
  • 51
2

This may not be helpful to anyone else, but I was hitting this when I had placed a exit(EXIT_FAILURE) in my code while refactoring a piece of code. I had assumed putting it in would crash the app right there and show me that it crashed there, but instead it was giving me this error and not showing where it had crashed.

EndersJeesh
  • 427
  • 1
  • 4
  • 20
  • 1
    You might want to consider using `fatalError()` or `fatalError("Your message here")` to crash your app. This gives the environment a chance to log details on its crash state. – Teng L Jul 21 '21 at 18:41
0

Xcode 11 beta 1:

This is a known issue when attempting to use code coverage against simulator targets. You must either use a later beta or run coverage against a physical device.

Allison
  • 2,213
  • 4
  • 32
  • 56