[英]Cocoapods always install old React (0.11.0)
我在运行时遇到问题pod install
Pod 总是降级 React Installing React 0.11.0 (was 0.55.4)
我的 pod 文件:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '9.0'
project 'BunteMobile.xcodeproj'
target 'BunteMobile' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for BunteMobile
pod 'Adjust', '~> 4.8.3'
pod 'Google-Mobile-Ads-SDK'
pod 'GoogleAds-IMA-iOS-SDK', '~> 3.7'
pod 'Fabric', '~> 1.7.0'
pod 'Crashlytics', '~> 3.9'
pod 'lottie-ios', :path => '../node_modules/lottie-ios'
pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'
target 'BunteMobileTests' do
inherit! :search_paths
# Pods for testing
end
end
当我从node_modules
定义 react 文件夹时,我读到了一些解决方案,但这个解决方案对我也不起作用。
我把这个放到 podfile 中:
pod 'yoga', path: './node_modules/react-native/ReactCommon/yoga'
pod 'React', :path => '../node_modules/react-native'
但仍然不起作用。 降级消失,但是当我尝试构建它时,出现以下错误:
/node_modules/react-native/React/Base/RCTConvert.h:17:9: could not build module 'yoga'
我尝试了与官方 RN 文档( https://facebook.github.io/react-native/docs/integration-with-existing-apps.html )相同的配置文件,但仍然出现相同的错误。
我将此添加到我的 podfile 中:
# Pods for React-Native start
pod 'React', :path => '../node_modules/react-native'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
# Pods for React-Native start
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
只需从 pod 文件中删除node_modules
行并在node_modules
手动添加库。
我观察到,当您运行react-native link <someLibrary>
时,RN 有时会自动将该库添加为 pod 依赖项。
在我的情况下,这个错误出现在 react-native-webview 中。
要解决这个问题:
我刚刚从 pod 文件中删除了node_modules/react-native-webview
行,然后
在其他库附近的 xCode 中添加了该库
将node_modules/some_library/ios/RNCWebView.xcodeproj
拖入项目库文件中
在build phases link binary with libraries
添加库依赖项build phases link binary with libraries
如果您要将 RN 集成到现有的本机应用程序中,您会希望您的 podfile 大致如下所示。 也就是说,您将通过pod 'React', :path => '../node_modules/react-native' ...
指定 React 依赖项的pod 'React', :path => '../node_modules/react-native' ...
您正在开发全新的 RN 应用程序吗? 如果是这样,您可能不想在pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'
包含pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'
因为它可能会导致您遇到的麻烦。
相反,在运行react-native link lottie-react-native
之前回到你的react-native link lottie-react-native
。 此命令可能将pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'
行添加到您的 podfile 中。 现在,您可以按照手动安装说明(我看到的不存在,但您可以检查这些说明,这将是相同的事情)或者您可以执行以下操作:从node_modules/lottie-react-native
删除lottie-react-native.podspec
node_modules/lottie-react-native
然后才运行react-native link lottie-react-native
。 依赖项不会添加到 podfile 中,而是作为静态库链接到二进制文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.