13

I keep getting the error:

The file "Blah" couldn't be opened because you do not have permission to view it. 

I tried the top 5 answers in this question -

"The file "MyApp.app" couldn't be opened because you don't have permission to view it" when running app in Xcode 6 Beta 4

But they do not work.

Note: I deleted the debug and release from the Test in the Build Settings and cleared the derived data multiple times.

enter image description here

info.plist

enter image description here

Community
  • 1
  • 1
PHP Web Dev 101
  • 515
  • 1
  • 7
  • 20
  • 1
    Did you clean and rebuild? – NobodyNada Sep 07 '15 at 20:13
  • @NobodyNada delete the derived data? – PHP Web Dev 101 Sep 07 '15 at 20:13
  • No, Product->Clean (Shift-Command-K). – NobodyNada Sep 07 '15 at 20:14
  • @NobodyNada Yes, I did that but it still gives the same error. – PHP Web Dev 101 Sep 07 '15 at 20:16
  • Are you sure `co.$(PRODUCT_NAME:rfc1034identifier)` is valid? That essentially makes the bundle identifier `co.myapp`... generally you'd want `com.mycompany.myapp`. You could also use `$(PRODUCT_BUNDLE_IDENTIFIER)`. Check the compiler settings also, and that it's set on default. – l'L'l Sep 07 '15 at 20:39
  • Xcode 7 GM is now available. Can you give it a try then tell us if the issue is still there? – Ducky Sep 15 '15 at 11:01
  • Did you check the file permissions? – Caleb Kleveter Sep 16 '15 at 17:06
  • Which OSX version do you use? I had some problems after _upgrading_ to El Capitan (GM) due to the new [System Integrity Protection (Rootless)](https://en.wikipedia.org/wiki/System_Integrity_Protection), which forbids to modify files in some locations. – tillz Sep 16 '15 at 17:17
  • Tried manually deleting the file through finder? – Shravya Boggarapu Sep 24 '15 at 05:04
  • Where exactly is the project located? – Sumeet Oct 13 '15 at 08:15
  • Are you accessing the file from your app or from an XCTest? There are configurations where you can't access a file from an XCTest while you can from your app. – Gerd Castan Oct 21 '15 at 15:41
  • Is this a runtime error? Are you trying to make your app open a file? Or is Xcode refusing to run your app? – Ben Leggiero Jun 07 '17 at 15:49
  • Possible duplicate of ["The file "MyApp.app" couldn't be opened because you don't have permission to view it" when running app in Xcode 6 Beta 4](https://stackoverflow.com/questions/24924809/the-file-myapp-app-couldnt-be-opened-because-you-dont-have-permission-to-vi) – Senseful Apr 24 '18 at 04:31
  • Refer to this [answer](https://stackoverflow.com/a/50167291/6521116) with a good summary of this issue. – LF00 May 04 '18 at 05:23

5 Answers5

2

Go to Build Settings -> Build Options. Then change the value of the "Compiler for C/C++/Objective-C" to Default Compiler.

smohn
  • 390
  • 1
  • 4
  • 15
2

I've just found another potential cause for this error

Xcode will say "you do not have permission" if the .app file does not contain a valid binary (you can inspect the .app file by right-clicking on it and selected Show Package Contents -- you're looking for something with an icon of a terminal with the green letters "exec")

The binary may be missing for a number of reasons (failed compilation, failed linking, etc) - but you can usually find a hint by clicking on the "warnings" tab above the file list in Xcode. In my case I was referencing a third-party library but needed to add it to the "Link Binary with Libraries" build phase

stevendesu
  • 13,153
  • 13
  • 76
  • 146
1

I faced the same problem today, in my case the application name was containing space like (X Y), In info.plist Xcode converts the name to (X-Y) in the Executable file property, so I changed the application name to be like (XY) without space and the problem disappeared ! hope this will help anybody :)

user2168496
  • 482
  • 1
  • 4
  • 11
0

It appears you are getting this error while running your XCTest target.

I've seen cases where the test target has no permission for files belonging to the app target.

This worked for me:

  • use XCode 7 (makes @testable import easier)
  • do NOT compile your app classes into your test target
  • instead DO import your app target into your XCTest class

Now you write the code that accesses the file in your app code that is compiled into your app target.

From your XCTest class you call the method in the app target that has the permission to access app files.

Gerd Castan
  • 5,141
  • 3
  • 35
  • 70
-1

Please make sure that you have this. If not you can edit that.

1.$(BUILT_PRODUCTS_DIR)/yourappname.app/yourappname

2.In info.plist make sure that Executable file value is this only "$(EXECUTABLE_NAME)"

3.You may be need to give permission to your folder as read & write. For this you need to follow these steps: a. Right click b.get info c. unlock it and give your password d. then give read & write permission to yourself.

Hope this will help you out. I had the same issue and i solved it by following these steps.

Abhishek
  • 328
  • 3
  • 10