1. 程式人生 > >pod react 之 [!] The name of the given podspec `yoga` doesn't match the expected one `Yoga

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檔案,當然獲取不到啦。

心得:

解決問題的時候,沒必要鑽牛角尖,可以先解決其他問題,有的時候,問題之間是想通的,其他問題解決的同時,這個問題也隨之解決了。