当前位置: 首页 > 工具软件 > REACT-CPP > 使用案例 >

MAC中老版本react-native项目运行的报错总结

淳于俊迈
2023-12-01

项目build:

error:'React/RCTBridgeDelegate.h' file not found

解决方法:进入ios文件夹,运行:pod install

pod install:

[!] /bin/bash -c  set -e #!/bin/bash # Copyright (c) Facebook, Inc. and its affiliates.

解决方法:这个是xcode 未指定命令行tool或者有多个tool造成的,在xode->Preference->Location中选用确定的xcode tool,bug修复

pod install:

fatal: unable to access 'https://github.com/rsocket/rsocket-cpp.git/': Failed to connect to github.com port 443: Connection refused

解决方法:看能不能ping通github,不能的话,在/etc/hosts文件中,加上github.com现在的IP地址;如果能ping通,那就是网络不稳定,确保网络连接后,多次试验

pod install:

[!] Invalid `Podfile` file: cannot load such file -- /Users/gm2022/Desktop/pentax/new/pentax/node_modules/react-native/scripts/react_native_pods.

解决方法:忘记了yarn或者npm install

pod install:    

[!] CocoaPods could not find compatible versions for pod "React/Core":
  In Podfile:
    react-native-fetch-blob (from `../node_modules/react-native-fetch-blob`) was resolved to 0.10.6, which depends on
      React/Core

None of your spec sources contain a spec satisfying the dependency: `React/Core`.

解决方法:

可将目录切换到工程根目录后,执行以下命令即可解决问题:

 grep -rl "s.dependency 'React/Core'" node_modules/ | xargs sed -i '' 's=React/Core=React-Core=g'

项目build:

fatal error: module map file '/Users/gm2022/Library/Developer/Xcode/DerivedData/pentax-fvbnkopcynnlzmdznslnrwlsazel/Build/Products/Debug-iphonesimulator/YogaKit/YogaKit.modulemap' not found

解决方法:

包是空的,xcode打开的文件错误,应该打开后缀为.xcworkspace的文件

npm install:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: pentax@0.0.1
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"17.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8" from @react-native-community/async-storage@1.12.1
npm ERR! node_modules/@react-native-community/async-storage
npm ERR!   @react-native-community/async-storage@"^1.12.1" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/gm2022/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:


解决方法:

npm版本太高导致,高版本更加严格

要么降级

要么使用这个代替:npm i --legacy-peer-deps

再运行就没有问题了。

App Run:

 No permission handler detected.

• Check that you link at least one permission handler in your Podfile.
• Uninstall this app, delete your Xcode DerivedData folder and rebuild it.
• If you use `use_frameworks!`, follow the workaround guide in the project README.

解决方法:

在Podfile中没有找到获取权限的包。

在Podfile中加入:

 permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways/Permission-LocationAlways.podspec"
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse/Permission-LocationWhenInUse.podspec"

在xcode上面product中选择Clean Build Folder

等待再运行

App Run:

Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.

解决方案:

删除报错代码,这里是有一个对ios的判断

 类似资料: