-
Notifications
You must be signed in to change notification settings - Fork 905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change default location of iOS and Android folder #1103
Comments
I'm having the same issue on iOS. Got it working by specifying the project-path:
|
Looking at the code it looks like
|
You can find full source code at TheWidlarzGroup/react-native-video#2005 |
Oh we should fix that. Would you like to contribute @jenshandersson? cc @grabbou |
Thanks @jenshandersson 👍
|
@hamidhadi Android works fine for me. I think the Line 136 in 9e44835
|
@jenshandersson Strange! I have this issue with Android as well! |
@hamidhadi make sure you're on the latest version of the |
Any updates on this bug? I've searched everywhere about how to not have to copy/paste my project into the "android" folder and instead tell the react-native module to look into a different directory instead. I also tried the same approach as the author and ran into the exact same error hmm.. |
the same error in android for me |
same issue on android, any solution? |
still same on android |
hi guy, is there a solution? |
same issue |
same issue on ios |
Steps to run the app from custom dir: Imagine you have file structure like below: Then you have to take those steps to have working iOS and Android Apps:
module.exports = {
project: {
ios: {
sourceDir: 'example',
},
android: {
sourceDir: 'example/android/',
},
},
}; Adjust paths for iOS:
+ require_relative '../../node_modules/react-native/scripts/react_native_pods'
- require_relative '../node_modules/react-native/scripts/react_native_pods'
+ require_relative '../../node_modules/@react-native-community/cli-platform-ios/native_modules'
- require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
- shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
+ shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
- echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../../node_modules/react-native/scripts/.packager.env"
+ echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../node_modules/react-native/scripts/.packager.env"
// ...
- open "$SRCROOT/../node_modules/react-native/scripts/launchPackager.command" || echo "Can't start packager automatically"
+ open "$SRCROOT/../../node_modules/react-native/scripts/launchPackager.command" || echo "Can't start packager automatically" (remember to run Android:
- apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
- includeBuild('../node_modules/react-native-gradle-plugin')
+ apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
+ includeBuild('../../node_modules/react-native-gradle-plugin')
project.ext.react = [
enableHermes: true, // clean and rebuild if changing
+ cliPath: "../../../node_modules/react-native/local-cli/cli.js",
]
- apply from: "../../node_modules/react-native/react.gradle"
+ apply from: "../../../node_modules/react-native/react.gradle"
// ...
- apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
+ apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
- url("$rootDir/../node_modules/react-native/android")
+ url("$rootDir/../../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
- url("$rootDir/../node_modules/jsc-android/dist")
+ url("$rootDir/../../node_modules/jsc-android/dist")
} Similar adjustments have to be made for new architecture blocks in mentioned files. |
There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
(I asked this on StackOverflow but nobody answered so I decided to report that here)
Environment
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:If I run react-native config in the root folder, I can see the correct configuration:
The problem is whenever I run react-native run-ios I get this error:
NOTE: I installed all the dependencies properly. Here is the result of the react-native --v command:
Reproducible Demo
react-native init
ios
andandroid
folders therereact-native.config.js
in the root directory and export project configuration as I provided in this issue(You can find in theDescription
section).react-native run-ios
orreact-native run-android
The text was updated successfully, but these errors were encountered: