所以这个问题是我上一个问题的后续: 如何从共享组件文件夹导入不同的应用程序?react / react-native
所以我创建了我自己的npm module,我将所有组件都存储在其中。这些组件可以被任意数量的应用程序使用。因为我将使这些组件高度可重用。
但我仍然偶然发现了一个问题。
我创建了一个使用这个库的加载组件:@react-native-community/masked-view。这个库需要在 /ios/Podfile 中安装一个依赖项。首先,我在一个 react-native 项目中创建了这个组件。
yarn add @react-native-community/masked-view
..
success Saved 1 new dependency.
cd ios/
pod install
..
Installing RNCMaskedView (0.1.6)
Pod installation complete! There are 33 dependencies from the Podfile and 31 total pods installed.
'
然后我运行了我的代码,加载组件工作。现在我想将它添加到包含我所有组件的 NPM module(同样是我自己创建的)。
所以我进入 /my-awesome-99-components/ ,它有自己的 package.json 因为它是一个module,我将在我正在处理的每个项目中导入它。
在 /my-awesome-99-components/
yarn add react react-native @react-native-community/masked-view
..
success Saved 1 new dependency.
// Created Loading.js - this is the loading component
yarn publish
..
在 /react-native-project-1/
yarn add my-awesome-99-components
..
Done in 3.17s.
cd ios/
Pod install
..
这就是问题出现的地方。现在 Podfile 不会安装 RNCMaskedView,因为显然我的module没有让项目知道它应该在 ios/Podfile 中安装一些包。
有谁知道为什么会发生这种情况,最好的解决方案是什么?
我感谢所有的帮助!