skip to Main Content

I’m working on a legacy react-native codebase, building the iOS app using Xcode 11.3. I got a sucessfull build after much trial and error, but I’m having some kind of permission issue to run the app in the simulator. I do not have access to a physical iOS device.

The file “***” couldn’t be opened because you don’t have permission to view it.
Domain: NSCocoaErrorDomain
Code: 257
Failure Reason: You don’t have permission.
Recovery Suggestion: To view or change permissions, select the item in the Finder and choose File > Get Info.
User Info: {
  NSFilePath = "/Users/***/Library/Developer/Xcode/DerivedData/***-dxvphugocaepzfaicmcbykxrlgrt/Build/Products/Debug-iphonesimulator/***.app";
}

I did some research and couldn’t find a solution that worked elsewhere. I double-checked the executable file is ${EXECUTABLE_NAME} and it matches the info.plist file. If I try to manually drag to install the app into the simulator, it says an error occurred. The file is there.

Failed to chmod /Users/***/Library/Developer/CoreSimulator/Devices/2CAAF9A3-3368-4BF8-B13D-C02888E9E653/data/Bundle/Application/7DADE8A3-0EC4-4AB2-B80B-E5E2BE84562C/AppName.app/AppName : No such file or directory

I tried giving permission with this cmd below, but it didin’t worked.

sudo chown -R username /Users/username/Library/Developer/Xcode

==============================================================
Edit:

I have been opening the project from ProjectName.xcworkspace as suggested.

Did pod deintegrate and pod install, deleted the derived data and cleaned build files many times.

I have permissions set for the folders using the commands supplied on one of the answers and gave Xcode permission on a system level as well.

Some extra information:

    System:
      OS: macOS 10.15.2
      CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
      Memory: 7.43 GB / 16.00 GB
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 10.24.1 - /usr/local/bin/node
      Yarn: 1.22.19 - ~/Documents/ArenaTest/victoria-royals-app/node_modules/.bin/yarn
      npm: 6.14.12 - /usr/local/bin/npm
      Watchman: 4.7.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    IDEs:
      Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.10 => 0.59.10 
    npmGlobalPackages:
      react-native-cli: 2.0.1

My paths don’t seem to contain any special character besides a - in the parent react-native folder like this: app-name.

I will try using the Xcodes App to build with different Xcode versions as suggested and will update accordingly.

If there is any more information needed, I’m more than happy to edit the question providing the extra information.

2

Answers


  1. Chosen as BEST ANSWER

    The previous dev excluded the simulator from the debug and release in Excluded_Arch, which lives in the User-Defined in Xcode 11.

    Removing the entry fixed my issue.


  2. I have no idea where to start so I’ll give you a bunch of possibilities. Test them out and let me know what worked and, if not, give me more information on what you’ve already tried, the results, and how your project is structured / which technologies you’re using.

    If you are using CocoaPods, run pod install in the iOS directory again and then clean, rebuild and re-run the app. Make sure you’re opening the project from the ProjectName.xcworkspace file, not the ProjectName.xcodeproj one.

    Make sure that your project name, current project directory and full path (e.g.: /Users/name/My Projects/Project Name), and app name do not contain any spaces or special characters, as this might cause permission issues.

    Issues could also arise if your project path is too long, for example if it’s inside the iCloud Drive folder, the inside a bunch of other folders, it would look something like this:

    /Users/name/Library/Mobile Documents/com~apple~CloudDocs/Work Projects/Company Name/Project Name/cloned project
    

    That’s getting too long (and full of spaces), which could cause problems.

    If that doesn’t work, you can try the following steps to tackle the permissions side of the issue:

    1. Reset the simulator. In the menu bar, go to Hardware > Erase All Content and Settings. This will reset the simulator to its original state. Alternatively, you can erase all content from all simulators with the command:
    xcrun simctl erase all
    
    1. Clean your build folder in Xcode by going to Product > Clean Build Folder or pressing Shift + Command + K.

    2. Attempt to fix the permissions for the DerivedData folder. You can do this by running the following commands in the terminal:

    sudo chflags -R nouchg ~/Library/Developer/Xcode/DerivedData
    sudo chmod -R 777 ~/Library/Developer/Xcode/DerivedData
    
    1. Similarly, do the same for the CoreSimulator folder:
    sudo chflags -R nouchg ~/Library/Developer/CoreSimulator
    sudo chmod -R 777 ~/Library/Developer/CoreSimulator
    
    1. Rebuild your project in Xcode and try running the app on the simulator again.

    If the issue persists after doing all of the above, consider testing if you can reproduce the issue after updating Xcode to a newer version, as sometimes compatibility issues can cause problems like this. For example, you could use XcodesApp (also available from Homebrew) to try Xcode 11.0, 11.1, 11.2 etc. If everything fails, try checking the React Native dependencies and updating them if possible.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search