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?

3
  • Have you resolved this issue? Jan 24, 2018 at 8:32
  • @LokeshChowdary Unfortunately not. Jan 26, 2018 at 13:01
  • I had error in test case. Once I fixed it, this issue disappeared. I have code coverage option enabled already.
    – John Doe
    Mar 5, 2019 at 7:49

6 Answers 6

21

Had this warning when I forgot to enable code coverage:

enter image description here

5
  • 1
    This fixed it for me too. Should be marked as the correct answer.
    – Ben Thomas
    Feb 8, 2018 at 9: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, 2018 at 8:11
  • 1
    didn't fix the issue, also this is option has been moved from that screen already Feb 24, 2019 at 9: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. May 6, 2019 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, 2019 at 14:38
11

Xcode 10+

Enable Code Coverage for Test scheme.

enter image description here

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.

2
  • Cleaning did not work for me. Always getting this error after tests run now on XCode 9.2
    – stonedauwg
    Jan 11, 2018 at 20:48
  • @stonedauwg im also getting this issue. smh ... i don't even know how to track this down. Jan 15, 2018 at 3:55
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.

1
  • 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, 2021 at 18:41
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.

2
  • This, unfortunately, didn't help me with the issue.
    – Nat
    Nov 22, 2018 at 8:05
  • didn't help the issue for me also Feb 24, 2019 at 9:27
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.