问题描述
我需要为特定的库使用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文档中(),具体来说就是:
In React Native documentation (https://facebook.github.io/react-native/docs/linking-libraries-ios) it is specifically said:
有什么办法可以防止这种情况发生?如果没有,那么最好的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.
所以我要做的是:
- 确保我已提交
- 然后我使用
yarn
或npm $ c $安装依赖项c>。
- 我删除了
Podfile
。 - 我运行了
react-本地链接dependency_name
- 然后我放弃对
Podfile
的更改(实际上是将其删除)
- Make sure I have committed all the changes to git.
- I then install the dependency using
yarn
ornpm
. - I delete the
Podfile
. - I run
react-native link dependency_name
- 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库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!