File couldn't be opened because you don't

2019-02-16 12:01发布

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

标签: ios xcode6
4条回答
孤傲高冷的网名
2楼-- · 2019-02-16 12:23

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 :)

查看更多
甜甜的少女心
3楼-- · 2019-02-16 12:36

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

查看更多
唯我独甜
4楼-- · 2019-02-16 12:37

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.

查看更多
萌系小妹纸
5楼-- · 2019-02-16 12:49

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.

查看更多
登录 后发表回答