无效的 `Podfile` 文件:“”处有意外标记

问题描述 投票:0回答:1

我正在尝试 POD 安装,但收到此错误 -

 Invalid `Podfile` file: unexpected token at ''
  target 'Holla' do
  > use_native_modules!
  pod 'RNIap', :path => '../node_modules/react-native-iap'

我尝试了所有的解决方案,我没有react-native-cli包,我的android Manifest.xml文件完全没问题,Pod版本更新,节点版本更新。

这是我的 POD 文件:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform- 
ios/native_modules'
require_relative '../node_modules/react-native-permissions/scripts/setup'

Resolve react_native_pods.rb with node to allow for hoisting
   require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
  "react-native/scripts/react_native_pods.rb",
{paths: [process.argv[1]]},
)', __dir__]).strip

platform :ios, '13'
prepare_react_native_project!
   pod 'GoogleUtilities', :modular_headers => true

setup_permissions([
   # 'AppTrackingTransparency',
   # 'Bluetooth',
   # 'Calendars',
   # 'CalendarsWriteOnly',
   'Camera',
   # 'Contacts',
   # 'FaceID',
   # 'LocationAccuracy',
   # 'LocationAlways',
   # 'LocationWhenInUse',
   # 'MediaLibrary',
   # 'Microphone',
   # 'Motion',
     'Notifications',
     'PhotoLibrary',
   # 'PhotoLibraryAddOnly',
   # 'Reminders',
   # 'Siri',
   # 'SpeechRecognition',
   # 'StoreKit',
   ])

   linkage = ENV['USE_FRAMEWORKS']
     if linkage != nil
   Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
   use_frameworks! :linkage => linkage.to_sym
   end

   target 'Holla' do
     config = use_native_modules!
   pod 'RNIap', :path => '../node_modules/react-native-iap'
   pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app'
   pod 'FirebaseCore', :modular_headers => true
     use_frameworks! :linkage => :static
    $RNFirebaseAsStaticFramework = true
   # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
   # Hermes is now enabled by default. Disable by setting this flag to false.
   # Upcoming versions of React Native may rely on get_default_flags(), but
   # we make it explicit here to aid in the React Native upgrade process.
   #:hermes_enabled => flags[:hermes_enabled],
    :hermes_enabled => false,
    :fabric_enabled => flags[:fabric_enabled],
   # Enables Flipper.
   #
   # Note that if you have use_frameworks! enabled, Flipper will not work and
   # you should disable the next line.
    :flipper_configuration => flipper_config,
   # An absolute path to your application root.
   :app_path => "#{Pod::Config.instance.installation_root}/.."
   )

   target 'HollaTests' do
   inherit! :complete
   # Pods for testing

     end

   post_install do |installer|
      installer.pods_project.targets.each do |target|
   target.build_configurations.each do |config|
   config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
   end
   end
  react_native_post_install(
  installer,
  # Set `mac_catalyst_enabled`to `true`in order to apply patches
  # necessa`enter code here`ry for Mac Catalyst builds
  :mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
 end
 end

这是我的 Package.Json 文件:

{
  "name": "Holla",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start --reset-cache",
    "test": "jest",
    "prettier": "prettier --write . --config .prettierrc.js",
    "prepare": "husky install",
    "postinstall": "patch-package"
 },
 "dependencies": {
  "@react-native-async-storage/async-storage": "1.19.0",
  "@react-native-clipboard/clipboard": "^1.14.1",
  "@react-native-community/hooks": "^3.0.0",
  "@react-native-community/masked-view": "0.1.11",
"@react-native-community/push-notification-ios": "^1.11.0",
"@react-native-firebase/app": "^18.0.0",
"@react-native-firebase/auth": "^18.5.0",
"@react-native-firebase/firestore": "^18.0.0",
"@react-native-firebase/messaging": "^18.5.0",
"@react-native-picker/picker": "^2.7.7",
"@react-navigation/material-bottom-tabs": "6.2.15",
"@react-navigation/native": "6.1.6",
"@react-navigation/native-stack": "6.9.12",
"@react-navigation/stack": "6.3.16",
"@reduxjs/toolkit": "^1.9.5",
"@rneui/base": "^4.0.0-rc.7",
"@rneui/themed": "^4.0.0-rc.7",
"@sayem314/react-native-keep-awake": "^1.2.2",
"@shopify/flash-list": "^1.6.4",
"@stripe/stripe-react-native": "0.35.1",
"axios": "^1.3.3",
"deprecated-react-native-prop-types": "^4.2.1",
"dotenv": "^16.0.3",
"firebase": "^9.22.0",
"i18next": "^22.4.9",
"iso-3166-1-alpha-2": "^1.0.1",
"lodash": "^4.17.21",
"lodash.memoize": "^4.1.2",
"lostjs": "^1.1.21",
"moment": "^2.29.4",
"nativewind": "2.0.11",
"patch-package": "^8.0.0",
"prop-types": "^15.8.1",
"react": "18.2.0",
"react-i18next": "^12.1.5",
"react-native": "0.71.8",
"react-native-animatable": "^1.4.0",
"react-native-bootsplash": "4.5.2",
"react-native-calendar-strip": "2.2.6",
"react-native-calendars": "1.1294.0",
"react-native-circular-progress": "1.3.9",
"react-native-confirmation-code-field": "7.3.1",
"react-native-date-picker": "4.2.14",
"react-native-device-info": "^10.13.1",
"react-native-draglist": "^3.6.1",
"react-native-dropdown-picker": "5.4.4",
"react-native-dropdown-select-list": "2.0.5",
"react-native-element-dropdown": "2.10.0",
"react-native-elements": "3.4.3",
"react-native-gesture-handler": "2.9.0",
"react-native-get-random-values": "1.9.0",
"react-native-iap": "^12.13.1",
"react-native-image-picker": "7.1.0",
"react-native-indicators": "0.17.0",
"react-native-keyboard-aware-scroll-view": "0.9.5",
"react-native-linear-gradient": "2.8.3",
"react-native-linear-gradient-degree": "0.0.1",
"react-native-localize": "3.0.2",
"react-native-modal": "13.0.1",
"react-native-multiple-select": "^0.5.12",
"react-native-permissions": "^3.10.1",
"react-native-push-notification": "^8.1.1",
"react-native-qrcode-svg": "6.2.0",
"react-native-raw-bottom-sheet": "2.2.0",
"react-native-reanimated": "3.1.0",
"react-native-restart": "0.0.27",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "^3.31.1",
"react-native-searchable-dropdown": "^1.1.3",
"react-native-searchable-dropdown-kj": "^1.9.0",
"react-native-sectioned-multi-select": "^0.10.0",
"react-native-sound": "^0.11.2",
"react-native-svg": "15.1.0",
"react-native-system-navigation-bar": "^2.6.4",
"react-native-toast-notifications": "3.4.0",
"react-native-toggle-element": "2.0.1",
"react-native-track-player": "^4.1.1",
"react-native-url-polyfill": "^2.0.0",
"react-native-vector-icons": "^10.0.3",
"react-native-vision-camera": "3.8.2",
"react-redux": "8.0.5",
"redux-persist": "6.0.0",
"stripe": "^15.5.0",
"sync-storage": "0.4.2",
"timezones-list": "^3.0.2",
"uuid": "^9.0.0",
"validator": "^13.11.0"
},
 "lint-staged": {
    "**/*": "prettier --write --ignore-unknown"
},
"devDependencies": {
"@babel/core": "7.22.15",
"@babel/preset-env": "7.20.2",
"@babel/runtime": "7.21.0",
"@react-native-community/eslint-config": "^3.2.0",
"@tsconfig/react-native": "^2.0.2",
"@types/expo": "^33.0.1",
"@types/jest": "^29.2.1",
"@types/lodash": "^4.14.191",
"@types/react": "^18.0.28",
"@types/react-native": "0.71.3",
"@types/react-native-indicators": "0.16.2",
"@types/react-test-renderer": "^18.0.0",
"@types/uuid": "^9.0.1",
"@types/validator": "^13.11.1",
"babel-jest": "^29.2.1",
"eslint": "^8.19.0",
"husky": "^8.0.3",
"jest": "^29.2.1",
"lint-staged": "^13.2.2",
"metro-react-native-babel-preset": "0.73.7",
"prettier": "2.8.8",
"react-native-dotenv": "^3.4.8",
"react-test-renderer": "18.2.0",
"tailwindcss": "3.2.7",
"typescript": "4.8.4"
},
 "jest": {
   "preset": "react-native"
 }
}

和 Manifest.xml 文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="com.android.vending.BILLING" />
   <application 
      android:name=".MainApplication"
      android:usesCleartextTraffic="true"
      tools:targetapi="28"
      android:label="@string/app_name" 
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false" 
      android:theme="@style/BootTheme"
      >
    <activity 
      android:name=".MainActivity" 
      android:label="@string/app_name" 
      android:launchMode="singleTask" 
      android:windowSoftInputMode="adjustResize" 
      android:exported="true"
    >
     <intent-filter>
         <action android:name="android.intent.action.MAIN"/>
         <category android:name="android.intent.category.LAUNCHER"/>
     </intent-filter>
    <intent-filter>
       <action android:name="android.intent.action.VIEW"/>
       <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="Holla"/>
    </intent-filter>
    </activity>
   </application>
  </manifest>

谢谢您的帮助!!

react-native cocoapods
1个回答
0
投票

我通过yarn add @react-native-community/cli解决了这个问题,因为任何原因都需要它,即使我不在我的项目中的任何地方使用它,如果有人知道原因会很高兴听到希望它能帮助其他人

© www.soinside.com 2019 - 2024. All rights reserved.