如何停止本机链接到具有Podspec的CocoaPods库? [英] How to stop react-native link from linking a library with CocoaPods with it has a podspec?

查看:58
本文介绍了如何停止本机链接到具有Podspec的CocoaPods库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为特定的库使用CocoaPods。但是,我不想将其用于其他任何用途,因为它通常会迫使我也将React及其依赖项添加到Podfile中,这很麻烦,并且可能导致以前的经验中出现的一些问题。

I need to use CocoaPods for a specific library. However I don't want to use it for any other because it usually forces me to add React and its dependencies to the Podfile as well, which is a nuisance and can lead to several issues as in previous experiences.

在React Native文档中( https:/ /facebook.github.io/react-native/docs/linking-libraries-ios ),具体来说就是:

In React Native documentation (https://facebook.github.io/react-native/docs/linking-libraries-ios) it is specifically said:


如果您的iOS项目使用CocoaPods(包含Podfile),并且链接的
库具有podspec文件,则react-native链接将使用Podfile链接库
。要支持非平凡的Podfile,请添加#在此行注释下方添加新的pod
到您希望添加pod的地方。

If your iOS project is using CocoaPods (contains Podfile) and linked library has podspec file, then react-native link will link library using Podfile. To support non-trivial Podfiles add # Add new pods below this line comment to places where you expect pods to be added.

有什么办法可以防止这种情况发生?如果没有,那么最好的Podfile配置是什么(例如在更新RN时),它不会中断?

Is there any way to prevent this? If not, what is the best Podfile configuration that doesn't break (when RN is updated for example)?

推荐答案

我使用的确实是一种解决方法。这不是很好,但是对我有用。理想的情况是,如果 react-native链接提供了 -noPods 标志,但没有提供。

The solution that I use is really a workaround. It is not great but it works for me. Ideally it would be nice if react-native link offered a -noPods flag but it doesn't.

react-native链接检查是否存在 Podfile ,如果没有 Podfile ,它会像往常一样链接依赖项。

react-native link checks to see if there is a Podfile, if there is no Podfile it links the dependency as normal.

所以我要做的是:


  1. 确保我已提交

  2. 然后我使用 yarn npm

  3. 我删除了 Podfile

  4. 我运行了 react-本地链接dependency_name

  5. 然后我放弃对 Podfile 的更改(实际上是将其删除)

  1. Make sure I have committed all the changes to git.
  2. I then install the dependency using yarn or npm.
  3. I delete the Podfile.
  4. I run react-native link dependency_name
  5. I then discard the changes to the Podfile (effectively undeleting it)

或者,您将 Podfile 重命名为其他名称,然后在将其重新命名后链接。

Alternatively you rename the Podfile to something else, and then rename it back after you have linked.

这篇关于如何停止本机链接到具有Podspec的CocoaPods库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆