我已经与这个错误斗争了好几天了,试图在一个新的工作中启动。在试图在react native cli项目上运行pod install时遇到问题,我已经尝试了这里所有可能的解决方案,不适用于我的。
错误:
[!] Invalid `Podfile` file: /Users/decagon/kumoafrica/node_modules/react-native/scripts/react_native_pods_utils/script_phases.rb:39: syntax error, unexpected <<
template =<<~EOS
^
/Users/decagon/kumoafrica/node_modules/react-native/scripts/react_native_pods_utils/script_phases.rb:40: unknown regexp options - ll
/Users/decagon/kumoafrica/node_modules/react-native/scripts/react_native_pods_utils/script_phases.rb:41: dynamic constant assignment
RCT_SCRIPT_POD_INSTALLATION_ROOT=$(pwd)
^
/Users/decagon/kumoafrica/node_modules/react-native/scripts/react_native_pods_utils/script_phases.rb:41: `$(' is not allowed as a global variable name
/Users/decagon/kumoafrica/node_modules/react-native/scripts/react_native_pods_utils/script_phases.rb:41: syntax error, unexpected end-of-input
RCT_SCRIPT_POD_INSTALLATION_ROOT=$(pwd)
^.
# from /Users/decagon/kumoafrica/ios/Podfile:1
# -------------------------------------------
> require_relative '../node_modules/react-native/scripts/react_native_pods'
# require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
# -------------------------------------------
podfile:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
install! 'cocoapods', :deterministic_uuids => false
target 'kumo' do
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
target 'kumoTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
package.json:
{
"name": "kumo",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"react": "17.0.2",
"react-native": "0.68.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"@types/jest": "^26.0.23",
"@types/react-native": "^0.67.3",
"@types/react-test-renderer": "^17.0.1",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.67.0",
"react-test-renderer": "17.0.2",
"typescript": "^4.4.4"
},
"resolutions": {
"@types/react": "^17"
},
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
}
如果还有什么需要的话请尽管说。
3条答案
按热度按时间z18hc3ub1#
不知道这现在是否有帮助,但如果你在M1芯片机器上从头开始运行React Native,我可以通过执行以下操作来解决这个问题:
经过几个小时的努力,这是真正让
pod install
为我工作的方法。同样的例子可以在这里找到:https://reactnative.dev/docs/environment-setup在“创建新应用程序”部分。
blpfk2vs2#
我认为你是Mac M1用户,所以按照以下步骤:
1.卸载本地cocoapods gem
1.安装自制程序
或Go to Site Web
1.最后通过Homebrew安装cocoapods
它将工作,否则检查this
nlejzf6q3#
我看到这个错误,因为我有一个错误的版本的cocoapods或pod.我不知何故安装cocoapods从cask使用
brew install --cask cocoapods
,并有一个过时的版本-1.5.2
,而最新版本(在撰写本文时)是1.12.0
为了解决这个问题,我不得不使用
brew uninstall --cask cocoapods
卸载过时的cocoapods包,并使用brew install cocapods
重新安装最新版本PS:你可以使用
pod --version
检查版本