最近將ReactNative業務集成進現有APP項目中,出現了幾個具有代表性的問題,下面記錄一下
問題1、
[!] CocoaPods could not find compatible versions for pod "React/RCTText":
In Podfile:
React/RCTText (from `./RN/node_modules/react-native`)
Specs satisfying the `React/RCTText (from `./RN/node_modules/react-native`)` dependency were found, but they required a higher minimum deployment target.
解決:將 platform :ios, '8.0' 改成:platform :ios, '9.0' 即可。
問題2、
[!] Unable to find host target(s) for *****Extension. Please add the host targets for the embedded targets to the Podfile.
Certain kinds of targets require a host target. A host target is a "parent" target which embeds a "child" target. These are example types of targets that need a host target:
- Framework
- App Extension
- Watch OS 1 Extension
- Messages Extension (except when used with a Messages Application)
解決過程1:網上有人說將cocoapods 降低一個版本,可以解決問題
$ gem list 查看安裝的cocoapods 版本都有哪些
cocoapods (1.5.3, 1.3.1, 1.1.1)
$ pod _1.3.1_ install (無效)
$ pod _1.1.1_ install (有效解決,但是會帶來'config.h' file not found問題,並且無論怎么配置都沒有用,項目始終報錯。解決方案可以參考:React Native 'config.h' file not found 問題、configure: error: C compiler cannot create executables問題解決過程記錄)
解決過程2:經過思考問題應該不在podfile,想從Extension 入手解決。
1、 打開XCode ,選擇HOST target
2、打開 target's 'General'
3、向下找到'Embedded Binaries',確定下 Extension target 是不是存在,如果存在的話,將其刪掉,重新添加。如果不存在的話,需要添加。
之后,重新pod install 安裝即可,一直困擾的'config.h' file not found 問題也解決了。
