在 Yarn Workspace Monorepo 中 React Native App

问题描述

我有一个使用 react native v0.61.5 构建的现有应用程序以及一个使用 React 和 Next.js 构建的网站。已经通过 GitLab 和 Vercel、SVG 解析器、webpack 配置等为 CI/CD 构建了许多配置。但是,我想使用 yarn 工作区将它们组合成一个 monorepo。我将应用程序目录放入包文件夹中。在根上运行 yarn init,添加

{
  "workspaces": {
   "packages": [
     "packages/*"
   ]
 }
}

然后我在应用程序的packages.json 中添加一个nohoist,这样本地构建文件仍然可以被正确引用,而无需进入ios 和android 文件夹并在任何地方添加大量../../

{
   "workspaces": {
    "nohoist": [
      "@react-native-community/blur","@react-native-community/checkBox","@react-native-community/google-signin","@react-native-community/masked-view","@react-navigation/bottom-tabs","@react-navigation/native","@react-navigation/stack","react-native","react-native-appearance","react-native-check-Box","react-native-device-info","react-native-expo-viewport-units","react-native-gesture-handler","react-native-iap","react-native-iphone-x-helper","react-native-keyboard-aware-scroll-view","react-native-maps","react-native-purchases","react-native-reanimated","react-native-safe-area-context","react-native-screens","react-native-simple-radio-button","react-native-svg","react-native-swipe-gestures","react-native-unimodules","react-native-vector-icons","react-native-view-shot","react-native-web","react-native-webview","react-router-dom","react-router-native","reactotron-react-native","expo","expo-apple-authentication","expo-av","expo-blur","expo-cli","expo-constants","expo-crypto","expo-facebook","expo-google-app-auth","expo-image-picker","expo-linear-gradient","expo-location","expo-media-library","expo-sharing","expo-updates","husky"
    ]
  }
}

我选择不在这里使用 glob 是为了过于谨慎和特别明确。但是当我在 ios 文件夹中运行 pod install 时,(我首先运行 pod repo update)我收到一个错误一个不完整的 pod 列表:

错误

❯ pod install                                                                                                                                                                                                              36%
Installing unimodules:
 [email protected] from ../node_modules/expo-apple-authentication/ios
 [email protected] from ../node_modules/expo-av/ios
 [email protected] from ../node_modules/expo-blur/ios
 [email protected] from ../node_modules/expo-linking/node_modules/expo-constants/ios
 [email protected] from ../node_modules/expo-crypto/ios
 [email protected] from ../node_modules/expo-facebook/ios
 [email protected] from ../node_modules/expo-font/ios
 expo-image-load[email protected] from ../node_modules/expo-image-loader/ios
 [email protected] from ../node_modules/expo-image-picker/ios
 [email protected] from ../node_modules/expo-linear-gradient/ios
 [email protected] from ../node_modules/expo-location/ios
 [email protected] from ../node_modules/expo-media-library/ios
 [email protected] from ../node_modules/expo-sharing/ios
 [email protected] from ../node_modules/expo-updates/ios
 [email protected] from ../node_modules/@unimodules/react-native-adapter/ios

Found some duplicated unimodule packages. Installed the ones with the highest version number.
Make sure following dependencies of your project are resolving to one specific version:
 expo-constants

Detected React Native module pods for RNCCheckBox,RNCMaskedView,RNDeviceInfo,RNGestureHandler,RNGoogleSignin,RNIap,RNPurchases,RNReanimated,RNSVG,RNScreens,RNVectorIcons,react-native-appearance,react-native-blur,react-native-maps,react-native-safe-area-context,react-native-view-shot,and react-native-webview
Analyzing dependencies

[!] Unable to find a specification for `UMCore` depended upon by `EXConstants`

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

预期输出(来自正常的存储库设置):

❯ pod install                                                                                                                                                                                                              35%
Installing unimodules:
 [email protected] from ../node_modules/expo-app-auth/ios
 [email protected] from ../node_modules/expo-apple-authentication/ios
 [email protected] from ../node_modules/expo-av/ios
 [email protected] from ../node_modules/expo-blur/ios
 [email protected] from ../node_modules/expo-linking/node_modules/expo-constants/ios
 [email protected] from ../node_modules/expo-crypto/ios
 expo-error-recovery@1.1.0 from ../node_modules/expo-error-recovery/ios
 [email protected] from ../node_modules/expo-facebook/ios
 expo-file-system@8.1.0 from ../node_modules/expo-file-system/ios
 [email protected] from ../node_modules/expo-font/ios
 expo-image-load[email protected] from ../node_modules/expo-image-loader/ios
 [email protected] from ../node_modules/expo-image-picker/ios
 [email protected] from ../node_modules/expo-keep-awake/ios
 [email protected] from ../node_modules/expo-linear-gradient/ios
 [email protected] from ../node_modules/expo-location/ios
 [email protected] from ../node_modules/expo-media-library/ios
 [email protected] from ../node_modules/expo-permissions/ios
 [email protected] from ../node_modules/expo-sharing/ios
 expo-sql[email protected] from ../node_modules/expo-sqlite/ios
 [email protected] from ../node_modules/expo-updates/ios
 expo-web-bro[email protected] from ../node_modules/expo-web-browser/ios
 [email protected] from ../node_modules/unimodules-app-loader/ios
 [email protected] from ../node_modules/unimodules-barcode-scanner-interface/ios
 [email protected] from ../node_modules/unimodules-camera-interface/ios
 [email protected] from ../node_modules/unimodules-constants-interface/ios
 [email protected] from ../node_modules/@unimodules/core/ios
 [email protected] from ../node_modules/unimodules-face-detector-interface/ios
 unimodules-file-system[email protected] from ../node_modules/unimodules-file-system-interface/ios
 [email protected] from ../node_modules/unimodules-font-interface/ios
 unimodules-image-load[email protected] from ../node_modules/unimodules-image-loader-interface/ios
 [email protected] from ../node_modules/unimodules-permissions-interface/ios
 [email protected] from ../node_modules/@unimodules/react-native-adapter/ios
 [email protected] from ../node_modules/unimodules-sensors-interface/ios
 [email protected] from ../node_modules/unimodules-task-manager-interface/ios

Found some duplicated unimodule packages. Installed the ones with the highest version number.
Make sure following dependencies of your project are resolving to one specific version:
 expo-constants

Detected React Native module pods for RNCCheckBox,and react-native-webview
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 82 dependencies from the Podfile and 89 total pods installed.

[!] The `Braille Skate [Debug]` target overrides the `ALWAYS_EMbed_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Braille Skate/Pods-Braille Skate.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag,or
    - Remove the build settings from the target.

[!] The `Braille Skate [Release]` target overrides the `ALWAYS_EMbed_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Braille Skate/Pods-Braille Skate.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag,or
    - Remove the build settings from the target.

在这里遗漏了一些简单的东西吗?第二,我通过 GitHub ghist 和 YouTube 上的教程在谷歌上环顾四周,但我似乎无法让它工作。是否有关于一般情况下更好的方法的建议?提前谢谢大家。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)