已安装yarn install react-native-unimodules
说明中的下一步要求我编辑项目Podfile。必要的添加是shown here。
这是我生成的Podfile
platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
target 'MyProjectName' do
# Pods for MyProjectName
pod 'React', :path => '../node_modules/react-native/', :subspecs => [
'Core',
'CxxBridge',
'DevSupport',
'RCTText',
'RCTNetwork',
'RCTWebSocket',
'RCTAnimation',
'RCTImage',
]
pod 'React-Core', :path => '../node_modules/react-native/React'
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
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-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
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 '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'
use_unimodules!
target 'MyProjectNameTests' do
inherit! :search_paths
# Pods for testing
end
use_native_modules!
end
target 'MyProjectName-tvOS' do
# Pods for MyProjectName-tvOS
target 'MyProjectName-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
下一步正在运行pod install
,它给出以下输出/错误:
$ pod install
Installing unimodules:
expo-app-loader-provider@5.0.1 from ../node_modules/expo-app-loader-provider/ios
expo-constants@5.0.1 from ../node_modules/expo-constants/ios
expo-file-system@5.0.1 from ../node_modules/expo-file-system/ios
expo-permissions@5.0.1 from ../node_modules/expo-permissions/ios
unimodules-barcode-scanner-interface@2.0.1 from ../node_modules/unimodules-barcode-scanner-interface/ios
unimodules-camera-interface@2.0.1 from ../node_modules/unimodules-camera-interface/ios
unimodules-constants-interface@2.0.1 from ../node_modules/unimodules-constants-interface/ios
unimodules-core@2.0.1 from ../node_modules/@unimodules/core/ios
unimodules-face-detector-interface@2.0.1 from ../node_modules/unimodules-face-detector-interface/ios
unimodules-file-system-interface@2.0.1 from ../node_modules/unimodules-file-system-interface/ios
unimodules-font-interface@2.0.1 from ../node_modules/unimodules-font-interface/ios
unimodules-image-loader-interface@2.0.1 from ../node_modules/unimodules-image-loader-interface/ios
unimodules-permissions-interface@2.0.1 from ../node_modules/unimodules-permissions-interface/ios
unimodules-react-native-adapter@2.0.1 from ../node_modules/@unimodules/react-native-adapter/ios
unimodules-sensors-interface@2.0.1 from ../node_modules/unimodules-sensors-interface/ios
unimodules-task-manager-interface@2.0.1 from ../node_modules/unimodules-task-manager-interface/ios
Analyzing dependencies
Fetching podspec for `EXAppLoaderProvider` from `../node_modules/expo-app-loader-provider/ios`
Fetching podspec for `EXConstants` from `../node_modules/expo-constants/ios`
Fetching podspec for `EXFileSystem` from `../node_modules/expo-file-system/ios`
Fetching podspec for `EXPermissions` from `../node_modules/expo-permissions/ios`
Fetching podspec for `React-Core` from `../node_modules/react-native/React`
Fetching podspec for `React-DevSupport` from `../node_modules/react-native/React`
Fetching podspec for `React-RCTActionSheet` from `../node_modules/react-native/Libraries/ActionSheetIOS`
Fetching podspec for `React-RCTAnimation` from `../node_modules/react-native/Libraries/NativeAnimation`
Fetching podspec for `React-RCTBlob` from `../node_modules/react-native/Libraries/Blob`
Fetching podspec for `React-RCTImage` from `../node_modules/react-native/Libraries/Image`
Fetching podspec for `React-RCTLinking` from `../node_modules/react-native/Libraries/LinkingIOS`
Fetching podspec for `React-RCTNetwork` from `../node_modules/react-native/Libraries/Network`
Fetching podspec for `React-RCTSettings` from `../node_modules/react-native/Libraries/Settings`
Fetching podspec for `React-RCTText` from `../node_modules/react-native/Libraries/Text`
Fetching podspec for `React-RCTVibration` from `../node_modules/react-native/Libraries/Vibration`
Fetching podspec for `React-RCTWebSocket` from `../node_modules/react-native/Libraries/WebSocket`
Fetching podspec for `React-cxxreact` from `../node_modules/react-native/ReactCommon/cxxreact`
Fetching podspec for `React-fishhook` from `../node_modules/react-native/Libraries/fishhook`
Fetching podspec for `React-jsi` from `../node_modules/react-native/ReactCommon/jsi`
Fetching podspec for `React-jsiexecutor` from `../node_modules/react-native/ReactCommon/jsiexecutor`
Fetching podspec for `React-jsinspector` from `../node_modules/react-native/ReactCommon/jsinspector`
Fetching podspec for `React` from `../node_modules/react-native/`
Fetching podspec for `UMBarCodeScannerInterface` from `../node_modules/unimodules-barcode-scanner-interface/ios`
Fetching podspec for `UMCameraInterface` from `../node_modules/unimodules-camera-interface/ios`
Fetching podspec for `UMConstantsInterface` from `../node_modules/unimodules-constants-interface/ios`
Fetching podspec for `UMCore` from `../node_modules/@unimodules/core/ios`
Fetching podspec for `UMFaceDetectorInterface` from `../node_modules/unimodules-face-detector-interface/ios`
Fetching podspec for `UMFileSystemInterface` from `../node_modules/unimodules-file-system-interface/ios`
Fetching podspec for `UMFontInterface` from `../node_modules/unimodules-font-interface/ios`
Fetching podspec for `UMImageLoaderInterface` from `../node_modules/unimodules-image-loader-interface/ios`
Fetching podspec for `UMPermissionsInterface` from `../node_modules/unimodules-permissions-interface/ios`
Fetching podspec for `UMReactNativeAdapter` from `../node_modules/@unimodules/react-native-adapter/ios`
Fetching podspec for `UMSensorsInterface` from `../node_modules/unimodules-sensors-interface/ios`
Fetching podspec for `UMTaskManagerInterface` from `../node_modules/unimodules-task-manager-interface/ios`
Fetching podspec for `yoga` from `../node_modules/react-native/ReactCommon/yoga`
[!] CocoaPods could not find compatible versions for pod "React/Core":
In Podfile:
React/Core (from `../node_modules/react-native/`)
None of your spec sources contain a spec satisfying the dependency: `React/Core (from `../node_modules/react-native/`)`.
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.
在对Github issue regarding this exact error output的响应之后,我搜索了整个项目目录的文件内容,但没有发现任何React-Core
的位置,可能被错误地定义为React/Core
这是我第一次编辑Podfile,我担心我可能在语法上弄糊涂了。
答案 0 :(得分:1)
我猜podspec
的名称已更改:React-Core
不在子文件夹中,而是在根文件夹中。这是我的React-Native 0.61.3
工作pod文件:
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'MyApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
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-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 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'ReactCommon', :path => '../node_modules/react-native/ReactCommon'
pod 'React-Core', :path => '../node_modules/react-native'
pod 'React', :path => '../node_modules/react-native'
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'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
end
答案 1 :(得分:0)
反应原生changed a lot of things in 0.60,其中之一是split React podspec into separate podspecs。
这意味着React
个podspec不再具有任何subspecs
。您遇到的错误是React/Core
,它以前是一个子规格,现在不再可用(它现在是单独导入的)。要解决此问题,请从subspecs
中删除Podfile
:
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
etc...
请注意,您可以在网上找到许多教程和文档,其中包含subspecs
定义。这样就是在React Native <= 0.59中完成的,并且在0.60中不再有效。