React Native App In Yarn Workspace Monorepo

Viewed 821

I have an existing app built using react native v0.61.5 as well as a website built using React and Next.js. There's lots of configuration already built into both projects for CI/CD through GitLab and Vercel, SVG resolvers, webpack configurations, etc. I, however, would like to combine them into a monorepo using yarn workspaces. I put the app dir into a packages folder. Ran yarn init on the root, added:

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

I then added a nohoist to the app's packages.json so the native build files could still be referenced correctly without having to go into the ios and android folders and add a ton of ../../ everywhere:

{
   "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"
    ]
  }
}

I opted to not use globs here to be overly cautious and extra explicit. But when I run pod install in the ios folder, (I do run pod repo update first) I get an error and an incomplete list of pods:

Error:

❯ pod install                                                                                                                                                                                                              36%
Installing unimodules:
 expo-apple-authentication@2.2.2 from ../node_modules/expo-apple-authentication/ios
 expo-av@8.1.0 from ../node_modules/expo-av/ios
 expo-blur@8.1.2 from ../node_modules/expo-blur/ios
 expo-constants@9.3.5 from ../node_modules/expo-linking/node_modules/expo-constants/ios
 expo-crypto@8.4.0 from ../node_modules/expo-crypto/ios
 expo-facebook@8.1.0 from ../node_modules/expo-facebook/ios
 expo-font@8.1.1 from ../node_modules/expo-font/ios
 expo-image-loader@1.0.1 from ../node_modules/expo-image-loader/ios
 expo-image-picker@8.1.0 from ../node_modules/expo-image-picker/ios
 expo-linear-gradient@8.1.0 from ../node_modules/expo-linear-gradient/ios
 expo-location@8.1.0 from ../node_modules/expo-location/ios
 expo-media-library@8.1.0 from ../node_modules/expo-media-library/ios
 expo-sharing@8.1.0 from ../node_modules/expo-sharing/ios
 expo-updates@0.1.3 from ../node_modules/expo-updates/ios
 unimodules-react-native-adapter@5.2.0 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.

Expected Output (from the normal repo setup):

❯ pod install                                                                                                                                                                                                              35%
Installing unimodules:
 expo-app-auth@9.2.0 from ../node_modules/expo-app-auth/ios
 expo-apple-authentication@2.2.1 from ../node_modules/expo-apple-authentication/ios
 expo-av@8.1.0 from ../node_modules/expo-av/ios
 expo-blur@8.1.2 from ../node_modules/expo-blur/ios
 expo-constants@9.2.0 from ../node_modules/expo-linking/node_modules/expo-constants/ios
 expo-crypto@8.3.0 from ../node_modules/expo-crypto/ios
 expo-error-recovery@1.1.0 from ../node_modules/expo-error-recovery/ios
 expo-facebook@8.1.0 from ../node_modules/expo-facebook/ios
 expo-file-system@8.1.0 from ../node_modules/expo-file-system/ios
 expo-font@8.1.1 from ../node_modules/expo-font/ios
 expo-image-loader@1.0.1 from ../node_modules/expo-image-loader/ios
 expo-image-picker@8.1.0 from ../node_modules/expo-image-picker/ios
 expo-keep-awake@8.1.0 from ../node_modules/expo-keep-awake/ios
 expo-linear-gradient@8.1.0 from ../node_modules/expo-linear-gradient/ios
 expo-location@8.1.0 from ../node_modules/expo-location/ios
 expo-media-library@8.1.0 from ../node_modules/expo-media-library/ios
 expo-permissions@8.1.0 from ../node_modules/expo-permissions/ios
 expo-sharing@8.1.0 from ../node_modules/expo-sharing/ios
 expo-sqlite@8.1.0 from ../node_modules/expo-sqlite/ios
 expo-updates@0.1.3 from ../node_modules/expo-updates/ios
 expo-web-browser@8.2.1 from ../node_modules/expo-web-browser/ios
 unimodules-app-loader@1.0.2 from ../node_modules/unimodules-app-loader/ios
 unimodules-barcode-scanner-interface@5.1.0 from ../node_modules/unimodules-barcode-scanner-interface/ios
 unimodules-camera-interface@5.1.0 from ../node_modules/unimodules-camera-interface/ios
 unimodules-constants-interface@5.1.0 from ../node_modules/unimodules-constants-interface/ios
 unimodules-core@5.1.2 from ../node_modules/@unimodules/core/ios
 unimodules-face-detector-interface@5.1.0 from ../node_modules/unimodules-face-detector-interface/ios
 unimodules-file-system-interface@5.1.0 from ../node_modules/unimodules-file-system-interface/ios
 unimodules-font-interface@5.1.0 from ../node_modules/unimodules-font-interface/ios
 unimodules-image-loader-interface@5.1.0 from ../node_modules/unimodules-image-loader-interface/ios
 unimodules-permissions-interface@5.1.0 from ../node_modules/unimodules-permissions-interface/ios
 unimodules-react-native-adapter@5.2.0 from ../node_modules/@unimodules/react-native-adapter/ios
 unimodules-sensors-interface@5.1.0 from ../node_modules/unimodules-sensors-interface/ios
 unimodules-task-manager-interface@5.1.0 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, 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
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.

Am I missing something easy here? And two, I've looked around on google, through GitHub ghist's and tutorials on YouTube, and I just can't seem to get it to work. Is there a suggestion for a better way to go about this in general? Thanks, everyone in advance.

0 Answers
Related