为什么 Pod 依赖管理器没有检测到安装所需的模块?

编程入门 行业动态 更新时间:2024-10-28 06:30:23
本文介绍了为什么 Pod 依赖管理器没有检测到安装所需的模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以这个问题是我上一个问题的后续:不同的应用程序如何从共享组件文件夹?反应/反应原生

所以我创建了自己的 npm 模块,我将所有组件都存储在其中.这些组件可以被任意数量的应用程序使用.因为我将使这些组件具有高度可重用性.

但我仍然偶然发现了一个问题.

我创建了一个使用这个库的加载组件:@react-native-community/masked-view.这个库需要在/ios/Podfile 中安装一个依赖项.首先我在一个 react-native 项目中创建了这个组件.

yarn 添加@react-native-community/masked-view..成功保存了 1 个新的依赖项.光盘 ios/吊舱安装..安装 RNCMaskedView (0.1.6)Pod安装完成!Podfile 有 33 个依赖项,总共安装了 31 个 Pod.

'

然后我运行了我的代码,Loading 组件就可以工作了.现在我想将它添加到包含我所有组件的 NPM 模块(同样是我自己创建的).

所以我进入/my-awesome-99-components/,它有自己的package.json,因为它是一个模块,我将在我正在处理的每个项目中导入它.

在/my-awesome-99-components/

yarn add react react-native @react-native-community/masked-view..成功保存了 1 个新的依赖项.//创建 Loading.js - 这是加载组件纱线发布..

在/react-native-project-1/

yarn 添加 my-awesome-99-components..在 3.17 秒内完成.光盘 ios/Pod 安装..

这就是问题出现的地方.现在 Podfile 不会安装 RNCMaskedView,因为显然我的模块没有让项目知道它应该在 ios/Podfile 中安装一些包.

有谁知道为什么会发生这种情况,最好的解决方案是什么?

感谢所有的帮助!

解决方案

您是否尝试过将 podspec 文件添加到您的存储库中?

您可以像

一样从 masked-view 包中修改 podspec 文件

需要'json'package = JSON.parse(File.read(File.join(__dir__, 'package.json')))Pod::Spec.new 做 |s|s.name = "RNCMaskedView"s.version = 包['版本']s.summary = 包['说明']s.authors = 包['作者']s.platforms = { :ios =>"9.0", :tvos =>9.0"}s.source = { :git =>"github/react-native-community/react-native-masked-view.git", :tag =>"v#{s.version}" }s.source_files = "node_modules/@react-native-community/masked-view/ios/**/*.{h,m}"s.dependency '反应'结尾

这里只更改源文件的路径

So this question is a follow up to my previous question: How can different apps import from a shared components folder? react / react-native

So I've created my own npm module which I store all my components in. These components can be used by as many apps as I like. Because I will be making those components highly reusable.

But I still have stumbled upon a problem.

I have created a loading component which uses this library: @react-native-community/masked-view. This library needs to install a dependency inside /ios/Podfile. First I created this component inside one of the react-native projects.

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.

'

So then I ran my code, and the Loading component works. Now I want to add this to the NPM module (that, again, I created myself) which will contain all my components.

So I go into /my-awesome-99-components/ which has its own package.json since it is a module which I will import in each project I'm working on.

In /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 ..

In /react-native-project-1/

yarn add my-awesome-99-components .. Done in 3.17s. cd ios/ Pod install ..

This is where the problem comes up. Now the Podfile won't install the RNCMaskedView because apparently my module doesn't let the project know that it should install some packages inside the ios/Podfile.

Does anyone know why this happens, and what would be the best solution for this?

I appreciate all the help!

解决方案

Have you tried adding a podspec file to your repo?

You can modify the podspec file from the masked-view package like

require 'json' package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) Pod::Spec.new do |s| s.name = "RNCMaskedView" s.version = package['version'] s.summary = package['description'] s.authors = package['author'] s.platforms = { :ios => "9.0", :tvos => "9.0" } s.source = { :git => "github/react-native-community/react-native-masked-view.git", :tag => "v#{s.version}" } s.source_files = "node_modules/@react-native-community/masked-view/ios/**/*.{h,m}" s.dependency 'React' end

only change here would be the path of the source files

更多推荐

为什么 Pod 依赖管理器没有检测到安装所需的模块?

本文发布于:2023-10-30 21:58:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544123.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:所需   管理器   检测到   模块   Pod

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!