Pods/RCT-Folly/folly/portability/Time.h 和不同类型的 Typedef 重新定义中的错误('uint8_t'(又名'unsigned char')与'enum Clockid_t')

sta*_*orn 13 ios react-native folly fbflipper

我正在审查 React Native 项目的源代码,但在构建它时遇到问题。

运行以下命令后

  1. npm install在项目的根部
  2. pod install在ios文件夹中

我在终端中收到以下消息:

sh: -c: line 0: syntax error near unexpected token `('

sh: -c: line 0: `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' /Users/myUser/dev/ReactExplorerApp(Android)/ios/Pods/RCT-Folly/folly/portability/Time.h'
Run Code Online (Sandbox Code Playgroud)

当我使用 XCode 构建应用程序时,我在 Time.h (...Pods/RCT-Folly/folly/portability/Time.h) 处收到以下错误消息:

Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

该应用程序使用“react-native”:“0.66.1”。我正在使用 cocoapods 版本 1.11.2、node 版本 14.17.2 和 XCode 版本 13.1

Pod 文件内容:

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

platform :ios, '11.0'

target 'ExplorerApp' do
  config = use_native_modules!
  pod 'GoogleSignIn'
  pod 'RNI18n', :path => '../node_modules/react-native-i18n'
  pod 'react-native-version-check', :path => '../node_modules/react-native-version-check'
  pod 'react-native-camera', path: '../node_modules/react-native-camera', subspecs: [
    'FaceDetectorMLKit',
    'BarcodeDetectorMLKit'
  ]

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )


  target 'ExplorerAppTests' 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_native_modules!
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end
Run Code Online (Sandbox Code Playgroud)

我针对类似问题尝试了很多解决方案,但没有成功。我尝试通过在 podfile 中注释掉 Flipper 来禁用它,并且还尝试将目标更改为 iOS 12。我还尝试在删除 podfile.lock 并运行后安装 pod,pod install --repo-update并且还运行了pod cache clean --all

我还尝试了这里的解决方案https://github.com/facebook/react-native/issues/31480 ,但"react-native": "0.64.1" // or higher 它对我不起作用,我不清楚他们所说的“从podfile.lock”如果仍然有错误。

git clone [repo url]编辑:[解决方案] 我通过在终端中实际运行而不是使用与 VSCode 交互的 Azure DevOps 的克隆按钮来摆脱此错误。

Avi*_*nan 12

导航到该文件=>ios/Pods/RCT-Folly/folly/portability/Time.h

评论这一行 =>typedef uint8_t clockid_t;

更改 =>_IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0_IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_12_0

2022 年 6 月更新答案

这可以通过在 post_install 下的 pod 文件中添加以下行来自动实现

`sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
Run Code Online (Sandbox Code Playgroud)