根据 react-native cli 文档,我们可以为 RN cli 指定每个平台的自定义配置。 我想更改每个平台文件夹的默认位置,因此我在项目根目录下添加了我的自定义
如果我在根目录中运行
问题是每当我运行
react-native.config.js
文件,您可以在此处找到它:module.exports = {
project: {
ios: {
project: './example/ios/example.xcworkspace',
},
android: {
sourceDir: './example/android/',
},
},
};
如果我在根目录中运行
react-native config
,我可以看到正确的配置:{
...
"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"
}
}
}
问题是每当我运行
react-native run-ios
时,我会遇到以下错误:error iOS project folder not found. Are you sure this is a React Native project?. Run CLI with --verbose flag for more details.
注意:我已正确安装了所有依赖项。以下是 react-native --v
命令的结果:
react-native-cli: 2.0.1
react-native: 0.62.0