drewag
drewag

Reputation: 94803

"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

Whenever I try to run my app in Xcode 6 Beta 4 I am getting the error:

The file "MyApp.app" couldn't be opened because you don't have permission to view it.

This error appears no matter what simulator or device I target.

I have tried:

Has anyone else run into this problem and found a solution?

Screenshot

Upvotes: 295

Views: 194577

Answers (30)

ScottyBlades
ScottyBlades

Reputation: 14073

You can also get this error when the path is incorrect or attempting to get the contents of a folder instead of a path.

Upvotes: 0

Srini
Srini

Reputation: 1646

My use case was somewhat unique. I was using the info_plist property of an app_spec to additionally specify info.plist properties via a Hash.

However, setting the CFBundleExecutable key resulted in the permissions error. Removing it did the job for me.

Upvotes: 0

jwezorek
jwezorek

Reputation: 9565

If you google the text of this error message you will find maybe 20 threads across StackOverflow, Apple dev forums, Reddit, etc. about Xcode failing to be able to run a compiled executable with this error message.

In these threads you will find many people offering various suggestions about how to fix the problem: changing product name to match project name, changing build phase options, something with info.plist, changing compilers to or from Clang, etc. Presumably the suggestions are offered in good faith because they solved the problem for someone, but the answers are so varied that it is clear that the error message is generic and this is an important point if you are receiving it: this error seems to mean that something is wrong with the binary. Ignore its actual text: it may have nothing to do with permissions.

There is no general solution to this error. The error message is totally generic; assume it means "bad binary file". The solution if you are receiving it depends on what you are trying to do, what has changed, why you are seeing this error all of a sudden. Google the specifics of your situation rather than this error message.

In my case, and I have a feeling this is a common case, what I was trying to do was build an old iOS project, nine years old I think, on modern Xcode. The solution was to switch to the legacy build system which led to a compilation error because in the old project there were not modern architecture targets, which could be fixed by manually adding them.

Upvotes: 6

Narendar Singh Saini
Narendar Singh Saini

Reputation: 3394

What I did is here:

  • I deleted VALIDARCHS from Project
  • I deleted VALIDARCHS from Target
  • Build Active Architecture Only = YES (for Debug) Architectures
  • Standard Architectures $(ARCHS_STANDARD)

Also, File -> Project/Workspace Settings == New Build System

Xcode Version 12.0 (12A7209)

Upvotes: 8

Chen Ni
Chen Ni

Reputation: 1164

Maybe consider installing the latest version of Xcode.

I did that after trying all the other solutions (which did not work for me) and the issue was automagically fixed.

Upvotes: 0

Vidhya Sri
Vidhya Sri

Reputation: 1823

None of the solutions worked for me in Xcode 10.3 when I added two objective-c files to my project. I fixed by following the below steps,

  1. Go to Build Phases
  2. Check if the .m file is present inside Compiler sources. If not add it
  3. Add -objc flag for compiler flags right next to the .m file

Upvotes: 0

Secondwave
Secondwave

Reputation: 245

This message will also appear if you use .m files in your project which are not added in the build phase "compiles source"

Upvotes: 0

Daniel Mavrakis
Daniel Mavrakis

Reputation: 592

None of the provided answers worked for me. In my case, I finally fixed the error by updating the target architectures in Build Settings/Architectures/Valid Architectures to $(ARCHS_STANDARD), as arm64 was missing. This was not prohibiting the project to build, although a warning was issued recommending updating the valid architectures, but the "app could not be opened" error was shown at run time.

I surmise this error is rather generic and not always linked with a permission issue, but may be displayed when the generated app package is invalid.

Upvotes: 2

Vidhya Sri
Vidhya Sri

Reputation: 1823

I got this issue in Xcode 10.1 after adding objective c files to my swift project. Got this working by following the below steps,

  • Add .m file to compile sources under Target -> Build Phases
  • Add -objc to the compiler flags right next to the .m file

Upvotes: 0

informatiker
informatiker

Reputation: 2879

My Application was working fine on XCode 9.4, but when I opened my project in XCode 10 I was experiencing this issue. For me the issue was the build setting. I found the answer in this page https://forums.developer.apple.com/thread/112141.

In short go to File > Workspace Settings… > Build System and change it to "Legacy Build System"

Upvotes: 11

Scott Loomis
Scott Loomis

Reputation: 69

I updated my cocoa pods and added new supported architectures in build settings and that fixed it.

Upvotes: 0

SmallChess
SmallChess

Reputation: 8146

The error message is generic and doesn't actually tell you what it really mean.

For me I had to restore earlier github reversions which gave:

armv7 armv7s arm64

to the architecture.

Upvotes: 2

evgenii
evgenii

Reputation: 303

I had the same issue with Xcode 10 & react-native. All the above solutions didn't help me.

My solution: Create a new project with the same name. And change project & workspace files with the ones from the duplicated project. And it works!!! (after some small build-issues with path etc)

Upvotes: 0

LF-DevJourney
LF-DevJourney

Reputation: 28564

I came to this issue both on simulator and device.

And there is a tricky phenomenon. If I copy the project to a new place, there is some chance this issue gone when I first run. But after I clean and run, this issue comes.

I have try almost all the solution from the answers to this question, but neither do.

With the help of the version control system git, I can check out the previous version of the code and to see what modification lead to this issue.

In my project the HEAD version is workable, and my latest umcommitted modification will lead to this issue.

So I checkout each file from the workable version of my code to locate the issue. When I checkout the coin.xcodeproj/project.pbxproj(coin is my app name), this issue gone.

Solution: just checkout the workable coin.xcodeproj/project.pbxproj, for my case I just use the HEAD version is ok.

git checkout HEAD coin.xcodeproj/project.pbxproj


To make it a summary:

Upvotes: 0

user3288482
user3288482

Reputation: 49

I fixed this by clearing my derived data from the preferences in xcode

Upvotes: 0

Jayprakash Dubey
Jayprakash Dubey

Reputation: 36447

I had the same issue in my project. Later on found that third-party (fmdb for SQLite) file used in project contained Info.plist.

Simply deleting the Info.plist file worked for me!

Info.plist

Upvotes: 10

Albert Renshaw
Albert Renshaw

Reputation: 17902

Having the problem on DEVICE too (not just simulator)?


The other solutions only fixed it for me on simulator, not device.

For me this problem occurred (in Xcode 6) when I would try to change the main info.plist properties whilst trying to change my app name.

In info.plist I had changed Executable File name to something other than the default ${EXECUTABLE_NAME}...

I had mistaken this field for the field that changes the name of the app under the icon on the springboard.

Upvotes: 150

Antony Raphel
Antony Raphel

Reputation: 2078

I've had same this error in Xcode 8.2. The reason I found out for me, another Info.plist is added in my project while adding library (manually copy).

So that Xcode is getting confused for selecting correct Info.plist.

I just removed that Info.plist from the added library.

Then it is working fine without any permission alert.

Upvotes: 29

jeddi
jeddi

Reputation: 651

For me the error was in the .plist file at the key CFBundleExecutable. I had renamed the executable removing a space that was between two words. (Eg: from "Wild Racer" to "WildRacer"). Took 1 day to spot it!!

Xcode is soooo unhelpful in the debugging!

Upvotes: 5

Radek
Radek

Reputation: 631

I had similar issues. Apparently I've included Info.plist from outside project folder. That lead to the same error, shown after every build (except after I run it after cleaning the project).

To fix it I simply had to include Info.plist from the project folder.

Upvotes: 2

Shreesh Garg
Shreesh Garg

Reputation: 562

Please also check if you have added any third party lib with plist. Some time third party lib has the info plist causing the issue .

Upvotes: 0

Dovahkiin
Dovahkiin

Reputation: 1239

Try "cmd+shift+k" to clean the project and rebuild. At least it worked for me

Upvotes: 13

Borzh
Borzh

Reputation: 5215

Select Scheme Menu by pressing needed button on the right of run/stop buttons:

Picture 1


Press Edit Scheme... :

Picture 2


Select your executable:

Picture 3

Upvotes: 0

Etan
Etan

Reputation: 17564

I had the issue that the AppDelegate was missing.

Creating a minimal one solved the issue:

import UIKit

@UIApplicationMain
final class AppDelegate: UIResponder,UIApplicationDelegate {
}

Upvotes: -1

swiftBoy
swiftBoy

Reputation: 35783

My goodness!! I spent hours to resolve this issue.

On XCode 7.3 I was having project with no issues.

Mistake I did

I just Added physical folders and moved my files into them, problem started.

I tried everything

  • Default compiler
  • Clean and build
  • Reset simulator and reboot simulator, Xcode, iPhone even mac
  • Updated Info.plist
  • Deleting Derived Data
  • Editing the permission on the folder of the project
  • Checking my architectures

nothing worked :(

How I resolved

I was about create new project and then I just deleted those physical folders I added, clean build and YESS!!

It works!!

enter image description here

Upvotes: 14

Alexander Khitev
Alexander Khitev

Reputation: 6861

I changed name to new name then I returned the old name to my project and it helped me.

Upvotes: 1

I use Xcode6 GM. I encountered the same problem. What I did was to go to Build Settings -> Build Options. Then I changed the value of the "Compiler for C/C++/Objective-C" to Default Compiler.enter image description here

Upvotes: 255

Nicolas Buquet
Nicolas Buquet

Reputation: 3955

On my part, what trigger this error was that I had, at the root of my resources folder, a folder with the same name as my final executable file.

So, when launching the executable, I think Xcode found the folder and had problem executing a folder! ;-)

Upvotes: 0

Tim
Tim

Reputation: 1894

I tried all of the listed answers and none of them was useful. The problem was due to existence of an another plist file linked from a submodule via cocoapods. Luckily this was my own module, so I just deleted this plist from the submodule project and reinstalled pods.

solution

Later on I understood that the key of the problem was in the name of that second plist: simply info.plist. You may rename the file and relink it via a sources section of a submodule

That second plist file had a unique name, so Xcode was not supposed to become frustrated. Even my target settings pointed on a main plist, not on a info.plist. Looks like Xcode takes special consideraions about that name

The bug reproduced in Xcode 6.4 and Xcode 7.0

Upvotes: 9

Pratik Patel
Pratik Patel

Reputation: 1421

Please check if you have changed Executable file => $(EXECUTABLE_NAME) to any other name. If you have changed this name then it shows this error. Please replace it with $(EXECUTABLE_NAME).

Upvotes: 17

Related Questions