gpt4 book ai didi

ios - "use_native_modules!"的 react-native ios Podfile 问题

转载 作者:可可西里 更新时间:2023-11-01 04:23:06 38 4
gpt4 key购买 nike

在我的 ios/目录中的 react-native 项目 (react-native@0.60) 中,我运行 pod install 并收到此错误:

[!] Invalid `Podfile` file: no implicit conversion of nil into String.

# from /Users/coryrobinson/projects/hhs2/ios/Podfile:37
# -------------------------------------------
#
> use_native_modules!
# end
# -------------------------------------------

我没有在这个 Podfile 中添加或更改任何内容 - 它都是 react-native 生成​​的。 (我没有 iOS 开发经验,所以这可能是一个简单的修复,我只是不知道要寻找什么:-|)感谢您的帮助!

这是我的 Podfile

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'hhs2' do
# Pods for hhs2
pod 'React', :path => '../node_modules/react-native/'
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 'RNFS', :path => '../node_modules/react-native-fs'

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'

target 'hhs2Tests' do
inherit! :search_paths
# Pods for testing
end

use_native_modules!
end

target 'hhs2-tvOS' do
# Pods for hhs2-tvOS

target 'hhs2-tvOSTests' do
inherit! :search_paths
# Pods for testing
end

end

最佳答案

正确答案如下:

1 - 你的 POD 文件应该在顶部包含这一行

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

2 - 确保你的 package.jsonnode_module 文件夹安装了这个模块

cli-platform-ios/native_modules

3 - 如果你在运行 yarn install 后没有找到 - 意味着你的机器中有旧的缓存 node_modules 并且你需要在重新安装包之前清理它。

4 - 清理缓存 yarn 缓存清理

5 - 确保你有这个文件 react-native.config.js 并且它的配置是有效的 - 它没有不存在的 NPM 包 - 这一步是最后一步主要是错误的原因

我的react-native.config.js 示例

module.exports = {
project: {
ios: {},
android: {},
},
assets: ['./assets/fonts/'],
dependencies: {}, // make sure this dependencies are all valid installed packages or empty if you don't need it
};

6 - 安装节点包 yarn install,您的 pod 现在应该可以工作了! pod install --repo-update

编码愉快!

关于ios - "use_native_modules!"的 react-native ios Podfile 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56917963/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com