pod react 之 [!] The name of the given podspec `yoga` doesn't match the expected one `Yoga

[!] The name of the given podspec `yoga` doesn't match the expected one `Yoga

解决办法:

1、我的Yoga的路径不对,看截图

我的node_modules文件夹是在我的项目的根目录下,所以我修改路径:

pod 'yoga', :path => './node_modules/react-native/ReactCommon/yoga'

修改之后pod install还是报错,不过路径已经没问题了,为啥还报错呢,我先把pod 'yoga'注释掉了,pod install 之后还是报错,错误内容如下:

[!] CocoaPods could not find compatible versions for pod "React/BatchedBridge":
  In snapshot (Podfile.lock):
    React/BatchedBridge

  In Podfile:
    React/BatchedBridge (from `../node_modules/react-native`)

None of your spec sources contain a spec satisfying the dependencies: `React/BatchedBridge (from `../node_modules/react-native`), React/BatchedBridge`.

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.

Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.

[!] Automatically assigning platform `ios` with version `8.0` on target `LucyApp` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

于是我继续把BatchedBridge注释掉:

然后pod install 成功了

先解决简单的,针对BatchedBridge pod出错问题,其他的成功了(比如react里的core),说明React的路径没有问题,只有BatchedBridge找不到,那么很有可能就是真的找不到了,也就是说没有这个东东,那么看了那么多大神集成的react为啥有呢,原因无非就是现在有这个东东了,那就是说版本太低的原因了,新版本有,就版本没有,于是我修改了版本:

将 "dependencies": {"react-native": "^0.40.0"}

修改成了0.53.3      "dependencies": {"react-native": "^0.53.3"}

重新npm intall一下,再pod intall,成功了,

然后再把注掉的pod 'yoga'打开,再次pod install,奇迹发生了,居然也成功了

总结:

pod yoya时出现错误  [!] The name of the given podspec `yoga` doesn't match the expected one `Yoga

1、可能是pod 'yoga', :path => './node_modules/react-native/ReactCommon/yoga'的路径不对,修改路径

2、react-native的版本不同,造成的,只有RN版本 >= 0.42.0的时候,才需要添加pod 'yoga', :path => './node_modules/react-native/ReactCommon/yoga'

3、而针对找不到BatchedBridge,原因无他,也是react-native版本太低造成的,RN版本高于0.45之后才必须导入BatchedBridge,也就是说之前的版本是没有这个东东的,所以找不到。

注:

关于pod yoya时出现错误,

对于0.4.0版本文件路径:

对于0.5.0版本文件路径:

一目了然:0.4.0版本的就没有yoga.podspec文件,当然获取不到啦。

心得:

解决问题的时候,没必要钻牛角尖,可以先解决其他问题,有的时候,问题之间是想通的,其他问题解决的同时,这个问题也随之解决了。

猜你喜欢

转载自blog.csdn.net/weixin_40200876/article/details/83618446
今日推荐