Error ios project folder not found are you sure this is a react native project

I am new to react-native I am facing an error that my IOS and Android folder are deleted by using this command (rm -rf node_modules ios android). Now I am trying to recover the IOS and Android fold...

I am new to react-native I am facing an error that my IOS and Android folder are deleted by using this command (rm -rf node_modules ios android). Now I am trying to recover the IOS and Android folder by using these commands npm install—> react-native upgrade —>react-native run-ios.But no success and facing same issue
error iOS project folder not found. Are you sure this is a React Native project?.
Please help me.

asked Aug 6, 2020 at 5:33

Aftab Farooq's user avatar

1

You should create a new React-Native project and copy all the source files to new project folder. Also, you should move your package.json to the new project folder but you need to change project name with the new one in your new project folder. After then,

npm install && react-native upgrade && react-native run-ios

answered Aug 6, 2020 at 5:42

anlgrses's user avatar

anlgrsesanlgrses

3234 silver badges12 bronze badges

After updating the latest version of React native 0.62 i have faced a problem while running react native android project. The error is noted as ” Android project not found. Are you sure this is a React Native project? If your Android files are located in a non-standard location (e.g. not inside ‘android’ folder) consider setting ‘project.android.sourceDir’ option to point to a new location. Run CLI with –verbose flag for more details. ” This error is mainly comes when we try to install new package in react native project and for some reason the package dose not install properly. To solve this error we have 2 Solutions. We will discus both solutions in current tutorial.

Screenshot of Error message:

Solution 1 :

1. Open your React Native Project Root Directory and locate android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json .

signing-config.json2. Delete the signing-config.json file and then again GoTo your react native project root directory and run again project using
reactnative runandroid command.  After this your react native project will run successfully.

Solution 2:

1. Sometimes if we have older version of react native and some of newly installed packages dose not support older version. Then you have to update the react native project using
reactnative upgrade command.

2. After done updating current project to new version this error should resolved.

Related posts:

(I asked this on StackOverflow but nobody answered so I decided to report that here)

Environment

System:
    OS: macOS 10.15.1
    CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
    Memory: 20.93 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.7.0 - /Volumes/JETDRIVE/.nvm/versions/node/v12.7.0/bin/node
    Yarn: 1.19.0 - /usr/local/bin/yarn
    npm: 6.10.0 - /Volumes/JETDRIVE/.nvm/versions/node/v12.7.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.8.4 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 28, 29
      Build Tools: 23.0.1, 28.0.3, 29.0.1
      System Images: android-29 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.3/11C29 - /usr/bin/xcodebuild
  Languages:
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0 
    react-native: 0.62.0 => 0.62.0 
  npmGlobalPackages:
    *react-native*: Not Found

Description

According to the react-native CLI documentation we can specify custom configuration based on each platform for RN CLI. I want to change the default location of each platform folders so I added my custom react-native.config.js to the root of the project which you can find that here:

module.exports = {
  project: {
    ios: {
      project: './example/ios/example.xcworkspace',
    },
    android: {
      sourceDir: './example/android/',
    },
  },
};

If I run react-native config in the root folder, I can see the correct configuration:

{
...
  "project": {
    "ios": {
      "sourceDir": "path-to-project-directory/example/ios",
      "folder": "path-to-project-directory",
      "pbxprojPath": "path-to-project-directory/example/ios/example.xcworkspace/project.pbxproj",
      "podfile": "path-to-project-directory/example/ios/Podfile",
      "podspecPath": null,
      "projectPath": "path-to-project-directory/example/ios/example.xcworkspace",
      "projectName": "example.xcworkspace",
      "libraryFolder": "Libraries",
      "sharedLibraries": [],
      "plist": [],
      "scriptPhases": []
    },
    "android": {
      "sourceDir": "path-to-project-directory/example/android/",
      "isFlat": true,
      "folder": "path-to-project-directory",
      "stringsPath": "path-to-project-directory/example/android/app/src/main/res/values/strings.xml",
      "manifestPath": "path-to-project-directory/example/android/app/src/main/AndroidManifest.xml",
      "buildGradlePath": "path-to-project-directory/example/android/build.gradle",
      "settingsGradlePath": "path-to-project-directory/example/android/settings.gradle",
      "assetsPath": "path-to-project-directory/example/android/app/src/main/assets",
      "mainFilePath": "path-to-project-directory/example/android/app/src/main/java/com/example/MainApplication.java",
      "packageName": "com.example",
      "packageFolder": "com/example",
      "appName": "app"
    }
  }
}

The problem is whenever I run react-native run-ios I get this error:

error iOS project folder not found. Are you sure this is a React Native project?. Run CLI with --verbose flag for more details.

NOTE: I installed all the dependencies properly. Here is the result of the react-native —v command:

react-native-cli: 2.0.1
react-native: 0.62.0

Reproducible Demo

  1. Create a RN project via react-native init
  2. Create a subfolder in the project and move ios and android folders there
  3. Create a react-native.config.js in the root directory and export project configuration as I provided in this issue(You can find in the Description section).
  4. Try to run the project via react-native run-ios or react-native run-android

После нескольких дней работы с React Native и Android я добавил несколько внешних библиотек, и все было хорошо.

После перезагрузки компьютера я вернулся в корень собственного проекта и набрал

npx react-native run-android

И вернул сообщение об ошибке

error Android project not found. Are you sure this is a React Native project? If your Android files are located in a non-standard location (e.g. not inside 'android' folder), consider setting `project.android.sourceDir` option to point to a new location. Run CLI with --verbose flag for more details.

Мой проект Android находится в стандартном месте: MyReactProjectandroid.

Любые идеи, что случилось или как это исправить?

5 ответов

Просто нашел решение. Вам просто нужно перейти в node_modules -> glob -> common.js.

Найдите options.allowWindowsEscape и установите для него значение false.

Это сработало для меня, и также потребовалось 3 часа, чтобы найти решение. Надеюсь, это сработает и для вас.


2

Uzzam Altaf
15 Май 2022 в 00:12

Таким образом, в основном проблема может заключаться в том, что вы можете запустить проект быстрого запуска expo CLI в «React native CLI Quickstart». Есть два пути: — https://reactnative.dev/docs/environment-setup

Проблема может быть решена: — 1) npm install -g expo-cli 2) expo init AwesomeProject

Cd npm start # можно также использовать: expo start


0

Shikhar Thakur
21 Дек 2021 в 15:29

Я нашел решение, которое работает, но до сих пор не знаю, что пошло не так. вероятно, из-за установки новых пакетов.

  1. Откройте корневой каталог моего проекта React Native.
  2. перейдите в androidappbuildintermediatessigning_configdebugout
  3. Удалите файл signing-config.json.
  4. вернуться в корневой каталог
  5. введите npx react-native run-android

Решение основано на этом сайте, надеюсь, это поможет другим.


4

Citizen-Dror
1 Окт 2020 в 11:43

Вы должны проверить свой манифест, я не закрыл тег


3

digital and olé
6 Мар 2021 в 12:50

Убедитесь, что у вас есть папки «android» и «ios» в корневом каталоге вашего проекта точно так, как показано на рисунках ниже. Если у вас нет этих папок, создайте их.

npm i react-native-eject
npm i @react-native-community/cli


react-native eject
react-native upgrade

enter image description here


1

Vega
5 Июн 2021 в 15:39

How to run a React Native app on iOS

by Soujanya PS

G3MMcylb2HPrpSi50yH6qM39qPcRawi7fP5x

I recently started to develop a React-Native app on iOS. This was my first foray into native app development. I was surprised by the ease and level of abstraction provided by React-Native’s command line interface. I was also curious to understand what happens under the hood when React-Native runs an app on a device or a simulator.

I spent a lot of time going through the relevant code. There was no one place which summarized what React-Native does to get the app working. Partly, that was the motivation to come up with this piece. I want to help any other person who is starting off afresh with React-Native app development.

React-Native provides command line utilities to run an app on iOS and Andriod simulators/devices. Without further ado, let’s try to understand the what and how of the process to run React-Native apps on iOS.

Behind the scenes

React-native provides this neat utility called init. It creates a native app template for you. This template creates the relevant Xcode project files under the iOS folder of the app.

React-Native apps can be launched on iOS simulators/physical devices by running the following command in the root folder of an app:

react-native run-ios

Successful execution would open the app on a simulator or a connected device. For this to happen, there are a bunch of steps which are executed when we run the above command.

run-ios command

React-Native provides a number of command line utilities to work with the app. These can be found under the local-cli folder of the React-Native node module. run-ios is one such utility which invokes the runIOS() function defined in the runIOS.js file. run-ios accepts certain options such as:

#Launch the app on a specific simulatorreact-native run-ios --simulator "iPhone 5"
#Pass a non-standard location of iOS directoryreact-native run-ios --project-path "./app/ios"
#Run on a connected device, e.g. Max's iPhonereact-native run-ios --device "Max's iPhone"
#Build the app in Release modereact-native run-ios --configuration Release

Device/Simulator selection

When no device is specified, run-ios would launch the app in Debug mode on a simulator by default. This is done by executing a series of xcrun simctl commands. They would first check the list of available simulators on Mac, pick one among them, and then boot the selected simulator.

Alternatively, if you wish to run the app on a physical device, plug the device to the Mac and then pass on the device details to the run-ios command.

The next step is to build the Xcode project of the app.

Building App code

Usually, the React-Native app Xcode project can be found in the iOS folder present under the root folder. The Xcode project is built using the xcodebuild command. Any options specified to run-ios such as the configuration etc. are passed on to this command.

By default, the Xcode project is built in Debug scheme. Once the project is successfully built, the app is installed and launched on the simulator or the connected device.

App code bundling in Debug Mode

During the development process, React Native loads our JavaScript code dynamically at runtime. For this, we need a server to bundle our app code and provide it as needed.

While the Xcode project is being built in Debug mode, an instance of Metro server is also started in parallel. Metro is the bundler used by apps created by the React-Native command line interface (CLI). It is used to bundle our app code in development. This helps us with faster and easier debugging by enabling hot reloading etc.

Metro server is configured to start on port 8081 by default. Once the app is launched in the simulator, a request is sent to the server for the bundle.

#Code in AppDelegate.m sends the request for the bundle: #index.bundle to serverjsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation  moduleName:@"MobileApp               initialProperties:nil     launchOptions:launchOptions];

The server then downloads all the required dependencies, bundles the JavaScript app code and sends it back to the app. After this step, you can see the app working on the simulator or a connected device.

App code bundling in Release Mode — Pre-packaging the JavaScript bundle

In release mode, we have to pre-package the JavaScript bundle and distribute it inside our app. Doing this requires a code change so that it knows to load the static bundle. In AppDelegate.m file, change jsCodeLocation to point to the static bundle if you’re not in debug mode.

#ifdef DEBUGjsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#elsejsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

This will now reference the main.bundle resource file. This file is created during the Bundle React Native code and images build Phase in Xcode. During this phase, react-native-xcode.sh script is run which bundles the JavaScript app code. This script can be found under the React-Native node module’s scripts folder.

Building the app from Xcode

Alternatively, the Xcode project can also be built within Xcode in Mac instead of using the React-Native CLI. Once done, the app can be launched on a simulator selected from the Xcode options or on a connected physical device.

bMWy-EbznFYSdPqaUKfVbFIvv2YSfmlulDkS

Xcode menu options to build app and launch it on a simulator

I hope this helped you understand the various steps which happen when we run a simple react-native run-ios command which magically brings up an app on iOS.

Some parts of the information provided here have been sourced from the React-Native home page. The rest is a product of me snooping around the code :)


Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started

In my case, I am using monorepo with multiple packages in a single repo. I solved this error by

  • Deleting the packages/myapp/node_modules
  • running yarn install from the project root. Not inside packages
  • its solved. Now can run yarn ios or yarn android commands

Note:
For autolinking libraries you need to have all of your dependencies in root package.json file also copied to packages/myapp/package.json file. See https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#how-can-i-use-autolinking-in-a-monorepo

Example:


  "dependencies": {
    "@react-native-community/datetimepicker": "^3.5.2",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/native": "^5.9.4",
    "@react-navigation/stack": "^5.14.5",
    "@reduxjs/toolkit": "^1.6.0",
    "@voximplant/react-native-foreground-service": "^2.0.0",
    "axios": "^0.21.1",
    "babel-eslint": "^10.0.3",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-plugin-import": "^2.18.2",
    ...
    ...

but make sure NOT TO COPY

    "react-native-cli": "^any version",

otherwise react-native-cli would collide and you will continue to see error like

Command `run-android` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.
error Command failed with exit code 1.

or

Command `run-ios` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.
error Command failed with exit code 1.

When working on React native, if you have seen the “React Native Android Project Not Found”error, you are not alone, there are many developers who are facing the same issue. let see the reason and solution how we can fix it.

When I am using React Native, below error is seen:

error Android project not found. Are you sure this is a React Native project? If your Android files are located in a non-standard location (e.g. not inside 'android' folder), consider setting `project.android.sourceDir` option to point to a new location.
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

How to Fix the “React Native Android Project Not Found” Error

To fix the Issue, follow the below Steps:

Step 1: Go to the “node_modules” Folder

Step 2: Find “glob”

Step 3: Open the “common.js” file

Step 4: You would be able to see the below parameters

options.allowWindowsEscape = true

Change the “options.allowWindowsEscape = true” True value to “False”.

It should be able to solve the “React Native Android Project Not Found” Error.

Conclusion

To Solve the “React Native Android Project Not Found” Error, First, Go to the “node_modules” Folder, Find “glob”, Open the “common.js” file, In options.allowWindowsEscape = true parameter, change the value to “False”.

Понравилась статья? Поделить с друзьями:
  • Error io qameta allure allurelifecycle could not add attachment no test is running
  • Error io pending com порт
  • Error invoking spell
  • Error invoking method при запуске javafx
  • Error invoking method перевод