[swift] "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:

  • Deleting all Derived Data from Organizer in Xcode
  • Repairing permissions on my drive
  • Manually elevating the permissions of the built MyApp.app
  • Restarting my computer

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

Screenshot

This question is related to swift xcode5 xcode6

The answer is


I'm using Xcode 6 GM. I encountered the same issue. What I did was to go to Build Settings -> Build Options (you can search "compiler"), and then changed the option of the "Compiler for C/C++/Objective-C" to Default Compiler.


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


I've fixed it by cleaning a build folder. Just went to 'Product' menu and Option+Click 'Clean'. After that a problem was resolved.


with X-code 6.3.2

[Build Settings] Options. [All]-[Build Options]-[Compiler for C/C++/Objective-C]-[Default compiler (Apple LLVM 6.1)]

Then rebuild the project, and it runs ok.


For me error was in file info.plist, field Bundle identifier. Somehow it was modified to

com.myCompany.${PRODUCT_NAME:rfc1034identifier}

from

com.myCompany.${PRODUCT_NAME}


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.


In Xcode do the following

Window --> Organiser --> Projects --> The app with the issue --> delete button in Derived Data.

I then cleaned the project and voila

works


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!


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


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:


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.


I found that changing my compiler to LLVM 6.0 in the Build Options was enough for me (xcode 6.1)

enter image description here


For me, a simple Product -> Clean worked great


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


I had similar issue (xCode 6.2) for sample code downloaded. I tried to set Executable Name to Default in Info.plist but this didn't worked.

Instead change Compiler for C/C++/Objective-C to Default compiler (Apple LLVM 6.0) instead of Unsupported Compiler(com.apple.compilers.llvmgcc42) for project.

Screenshot


Check permissions to read+write for project folder (Right Click for project folder in Finder > Get Info)


I had this similar problem. Somehow my value for the key Executable File got mixed up. Just change it back to ${EXECUTABLE_NAME} (Under your project > Info). Worked for me!


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.


Sometimes opening old project in new version Xcode will get this message.

Go to Issue navigator and follow the warning hint 'Upate to reconmmented settings'.

Boom, magic!


I was able to restore my project from a pre-xcode 6.1 backup,

Once I open my workspace from a different directory, I was able to run my target without this error. The simulator also works fine now.


I recently meet the same problem for running an old project (initially created in Xcode 4.x) in Xcode 6.0.1.

I fixed the problem by changing the Architectures in Building Settings to the default value, which is "Standard architectures(armv7,arm64)".

Hope this could help anyone who got similar problems :)


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


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 .


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)


I would go to the folder where your Xcode docs are and hit command + I to get info. At the bottom, hit the lock to unlock the folder to edit permission. If permissions look good, check the box that says to apply to enclosed folders and let that do it's thing. I haven't seen this personally and not sure if that's what you were saying in your post when you edit the build permissions.


I fixed this myself switching between "arm32" and "arm64" architectures. From the "Build Settings", I modified "Architectures" and "Valid Architectures" from "arm32" to "arm64" and it worked. After changing a number of other settings, switching between arm32 and arm64 no longer makes a difference, so I'm skeptical if this was the route cause.

Previously I tried all the other suggestions here:

  • plist was unmodified
  • EXECUTIBLE_NAME was unmodified
  • Build Clean
  • Delete DerivedData
  • Default Compiler

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


I've had this error with a number of my older projects that I am getting out of the cupboard to update. It seems that using Xcode 6 with older code seems to bring this about for some reason.

I have fixed this in all projects that I have done this with by:

  1. Delete Derived Data
  2. in Product: do a clean
  3. go to Build Settings in the project Target and go to Build Options and change the value of the "Compiler for C/C++/Objective-C" to 'Default Compiler'.

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.


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

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"


What solved it for me was setting Build Active Architecture Only from No to Yes.


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


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

In my case main.m containing the main(...) function was not contained in the list of "Compile Sources" in "Build Phases". To check if this is the case, enter into Build Phases and look, if your main.m appears in the "Compile Sources" list.


In my case it helped just to close Xcode, repaired the permissions with the Disk Utility. Only after a reboot it worked like a charm.


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.


I had the issue that the AppDelegate was missing.

Creating a minimal one solved the issue:

import UIKit

@UIApplicationMain
final class AppDelegate: UIResponder,UIApplicationDelegate {
}

Don't know if the problem is related but maybe it can be a solution for anyone pulling the hairs like me.

In my case, I have a project with a lot of targets. Each target is a customisation of that base project which is a Cocoa Touch Static Library and the targets, Applications. Even if the main file is added into the library compilation, but not in each target, that error message appears. So what I did? Manually added the main file to each target in the Compile Sources section and bingo, all fine.


I had this issue when my appdelegate class was not linked against my main app target but a separate static framework. Linking it directly against the target app fixed the issue.


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! ;-)


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


I got same error on my Xcode 6.1.1 for a project downloaded from gitHub which was committed 4 years ago. For me, setting Architectures to the default value Standard architectures(armv7,arm64) and Compiler for C/C++/Objective-C to Default Compiler in Building Settings worked.


Product -> Clean (command shift K) fixed it for me


Well in my case, I just rename the Bundle Name and Executable file values in info.plist same as project name. It worked for me.


That's because you may using the repository cloned from the git or svn. Try to clone another new version and run it.


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


What we didn't do right was to not apply with the accurate code when signing in the Build Settings. We fixed the issue up this way: Enter into Build Settings >> Code Signing >> Code Sign Identity. Then, apply with your iOS Developer ID for 'Debug', but be sure to apply with your iOS Distribution Profile for 'Release' We didn't apply correctly, so we couldn't have permission to ask for the App from the server, actually. Anyway this post forced us to revise all the parameters and requirements, so we pretty appreciate all your answers. Regards, T.


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


My solution was:

  1. Enter this in your Terminal: open ~/Library/Developer/CoreSimulator/Devices/

  2. Delete the appropriate folder

  3. Compile again an it should work


As i have also faced this issue today morning and none of the answers helped me out particularly in my case. And after trying for hours i figured out the issue.

Actually while working in storyboard by mistake, i just renamed my "Main.storyboard" to ".storyboard" and changing it back to "Main.storyboard" solved my issue.

SOLUTION(As per my issue): May be you have renamed any file due to which xcode couldn't load it and raised an issue. For example: as mentioned above the case of changing "Executable File" name
Possible Issue area: May be the last few files you were working in.


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


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.


1) Go Firstly Build Options.

2) Then changed the value of the "Compiler for C/C++/Objective-C" to Default Compiler.

clean and working :-)


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)


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


Examples related to swift

Make a VStack fill the width of the screen in SwiftUI Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code in Xcode 10 Convert Json string to Json object in Swift 4 iOS Swift - Get the Current Local Time and Date Timestamp Xcode 9 Swift Language Version (SWIFT_VERSION) How do I use Safe Area Layout programmatically? How can I use String substring in Swift 4? 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator Safe Area of Xcode 9 The use of Swift 3 @objc inference in Swift 4 mode is deprecated?

Examples related to xcode5

OS X Framework Library not loaded: 'Image not found' "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 Duplicate symbols for architecture x86_64 under Xcode iOS 7 - Failing to instantiate default view controller Undefined symbols for architecture arm64 iOS 7 status bar overlapping UI Find provisioning profile in Xcode 5 iOS 7 App Icons, Launch images And Naming Convention While Keeping iOS 6 Icons Is it possible to install iOS 6 SDK on Xcode 5? Provisioning Profiles menu item missing from Xcode 5

Examples related to xcode6

'Framework not found' in Xcode No suitable records were found verify your bundle identifier is correct unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard Move a view up only when the keyboard covers an input field My prerelease app has been "processing" for over a week in iTunes Connect, what gives? Programmatically navigate to another view controller/scene Changing the Status Bar Color for specific ViewControllers using Swift in iOS8 Change tab bar item selected color in a storyboard How do I change UIView Size? How to get textLabel of selected row in swift?