Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

React-Native change default location of iOS and Android folder

$
0
0

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

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>