Change default location of iOS and Android folder
See original GitHub issue(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
- Create a RN project via
react-native init
- Create a subfolder in the project and move
ios
andandroid
folders there - Create a
react-native.config.js
in the root directory and export project configuration as I provided in this issue(You can find in theDescription
section). - Try to run the project via
react-native run-ios
orreact-native run-android
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (2 by maintainers)
Top Results From Across the Web
React-Native change default location of iOS and Android folder
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...
Read more >React-Native change default location of iOS and Android folder
iOS : React-Native change default location of iOS and Android folder [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] ...
Read more >[iOS] How do I change the default save location? - PDF Viewer
Open the Settings.app · Scroll down to "PDF Viewer" and tap it · Select "Document Storage" · Choose your default save location.
Read more >Android file management: An easy-to-follow guide
With Android 6.0 through 7.1, the system-level file manager is somewhat hidden: You have to look in the Storage section of your system...
Read more >View and modify files and folders in Files on iPhone
Tap Browse at the bottom of the screen, then tap an item on the Browse screen. If you don't see the Browse screen,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looking at the code it looks like
react-native.config.js
is being ignored for iOS. The script simply looks for project/workspace in the root or--project-path
.https://github.com/react-native-community/cli/blob/4870ac55811d9c1491f2730088f3cb96f4f3c049/packages/platform-ios/src/commands/runIOS/index.ts#L52
I’m having the same issue on iOS. Got it working by specifying the project-path:
react-native run-ios --project-path example/ios
. But I feel this shouldn’t be needed?