【发布时间】:2021-03-31 00:12:27
【问题描述】:
按照链接中的步骤将 react native 集成到现有项目中没有帮助。
链接: https://reactnative.dev/docs/integration-with-existing-apps
配置
Mac OS X - 10.15.6 (19G2021)
XCode - 12.1 (12A7403)
React Native Cli - 2.0.1
React Native - 0.63.4
package.json
{
"name": "MyReactNativeApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "yarn react-native start"
}
"dependencies": {
"react-native": "^0.63.4"
}
}
Podfile
source 'https://github.com/CocoaPods/Specs.git'
# Required for Swift apps
platform :ios, '11.0'
use_frameworks!
# The target name is most likely the name of your project.
target 'MyReactNativeApp' do
# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
pod 'React', :path => '../MyReactNativeApp/node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTText',
'RCTNetwork',
'RCTWebSocket', # needed for debugging
# Add any other subspecs you want to use in your project
]
# Explicitly include Yoga if you are using RN >= 0.42.0
pod "Yoga", :path => "../MyReactNativeApp/node_modules/react-native/ReactCommon/yoga"
# Third party deps podspec link
pod 'DoubleConversion', :podspec => '../MyReactNativeApp/node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../MyReactNativeApp/node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../MyReactNativeApp/node_modules/react-native/third-party-podspecs/Folly.podspec'
end
当我运行 pod install 时。我收到一个错误
[!] CocoaPods could not find compatible versions for pod "React/Core":
截图:
我检查了现有的线程。没有什么可以正常工作。我还做了 pod 'React' 移除了其他所有东西,结果是
- 已弃用
- 它未被检测为模块。未找到模块 - 我 将为此分开问题。
【问题讨论】:
-
你试过
pod update吗? -
是的,我试过了,但没用。
-
为什么不在安装前检查它的兼容性?
-
按照官方文档中的说明完成。如果我确实删除它们或更改兼容性,则会出现其他问题。我发布了另一个问题,其中我删除了所有子规范并使用了 React,其中提到了它已被弃用,并带有相应的错误。 @ElTomato
-
糟糕...这是我的误会。我以为您正在尝试将其用于 macOS。对此我很抱歉。
标签: ios swift react-native