无效的podfile文件意外模板EOS

发布于 2025-01-26 22:47:25 字数 3946 浏览 1 评论 0原文

我已经在数天内与这个错误作斗争,试图从一份新工作开始。在试图在React Native CLI项目上安装POD时遇到问题,我尝试了这里的所有可能解决方案,但与我的关系不起。

错误:

[!] 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"
    ]
  }
}

如果需要其他要求,请提供帮助。

i have battling with this error for days now, trying to start up at a new job. Having issues while trying to run pod install on a react native cli project, i have tried every possible solution on here, doesnt work with mine.

The errors:

[!] 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'
 #  -------------------------------------------

The 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"
    ]
  }
}

if anything else is needed ask, please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我不在是我 2025-02-02 22:47:25

不知道这是否有帮助,但是如果您在M1芯片机上从头开始运行React Antial,我可以通过这样做来解决此问题:

cd ios
bundle install
bundle exec pod install

经过数小时的挣扎,这是实际制作POD的方法安装为我工作。

可以在此处找到相同的示例: https://reaectnative.dev/docs/docs/envorirnment-setup 在“创建新应用程序”部分下。

Don't know if this is helpful now but if you're running React Native from scratch on a M1 Chip machine I was able to fix this issue by doing:

cd ios
bundle install
bundle exec pod install

After hours of struggle this was the way to actually make for pod install work for me.

This same example can be found here: https://reactnative.dev/docs/environment-setup under the "Creating a new application" section.

眼泪淡了忧伤 2025-02-02 22:47:25

我看到了这个错误,因为我有一个错误的Cocoapods或Pod。我以某种方式使用brew install -cocoapods以某种方式从桶中安装了可可录,并且具有过时的版本 - 1.5.2,而最新版本(在写作时)为1.12.0

要解决此问题,我不得不使用使用brew Unstall -cocoapods卸载过时的Cocoapods软件包,然后使用最新版本重新安装了一个最新版本
brew brew install cocoapods,然后做brew link cocoapods

ps:您可以使用pod -version检查版本

I was seeing this error as I was having a wrong version of cocoapods or pod. I somehow installed cocoapods from cask using brew install --cask cocoapods and that had an outdated version - 1.5.2 while latest version(at the time of writing) was 1.12.0

To fix this issue, I had to then uninstall outdated cocoapods package using brew uninstall --cask cocoapods and reinstalled a latest version using
brew install cocoapods and then do brew link cocoapods

PS: You can check versions using pod --version

风为裳 2025-02-02 22:47:25

我认为您是Mac M1用户,因此请执行以下步骤:

  1. 卸载本地可可录GEM

      sudo gem卸载可可录
     
  2. 安装Homebrew

     /bin/bash -c“ $(curl -fssl https://raw.githubusercontent.com/homebrew/install/install/head/head/install.sh)”
     


    转到网站web

  3. 最终通过Homebrews通过Homebrews安装CocoApods

     酿造CocoApods
     

,它将起作用,否则检查

I think you are Mac M1 user, so follow this steps :

  1. Uninstall the local cocoapods gem

    sudo gem uninstall cocoapods
    
  2. install Homebrew

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    

    or
    Go to Site Web

  3. Finally install cocoapods via Homebrew

    brew install cocoapods
    

And it will Work, Otherwise check this

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文