简体   繁体   English

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

[英]Error in Pods/RCT-Folly/folly/portability/Time.h and Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

I'm reviewing the source code of a react native project, but I'm having issues building it.我正在查看 react native 项目的源代码,但在构建它时遇到了问题。

After running the following运行以下命令后

  1. npm install at the root of the project npm install在项目根目录下
  2. pod install at the ios folder pod install在 ios 文件夹中

I got the following message in the terminal:我在终端收到以下消息:

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'

And when I build the application with XCode, I get the following error message at the Time.h (...Pods/RCT-Folly/folly/portability/Time.h):当我使用 XCode 构建应用程序时,我在 Time.h (...Pods/RCT-Folly/folly/portability/Time.h) 处收到以下错误消息:

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

The app uses "react-native": "0.66.1".该应用程序使用“react-native”:“0.66.1”。 I'm using cocoapods version 1.11.2, node version 14.17.2 and XCode version 13.1我正在使用 cocoapods 版本 1.11.2、节点版本 14.17.2 和 XCode 版本 13.1

Podfile content: Podfile 内容:

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

I tried many solutions for similar issues, but didn't work.我尝试了许多类似问题的解决方案,但没有奏效。 I tried disabling Flipper by commenting it out in the podfile and I also tried changing the target to iOS 12. I also tried installing the pods after removing the podfile.lock and running pod install --repo-update and I also ran pod cache clean --all我尝试通过在 podfile 中将其注释掉来禁用 Flipper,我还尝试将目标更改为 iOS 12。我还尝试在删除 podfile.lock 并运行pod install --repo-update后安装 pod,我还运行了pod cache clean --all

I also tried the solution here https://github.com/facebook/react-native/issues/31480 for "react-native": "0.64.1" // or higher but it didn't work for me and I'm not clear on what they refer with "remove the relevant lines from the podfile.lock" if there are still errors.我也在这里尝试了解决方案https://github.com/facebook/react-native/issues/31480 for "react-native": "0.64.1" // or higher ,但它对我和我都不起作用如果仍然有错误,我不清楚他们用“从 podfile.lock 中删除相关行”指的是什么。

Edit: [Solution] I got rid of this error by actually running git clone [repo url] in my terminal instead of using Azure DevOps's Clone button that interfaces with VSCode.编辑:[解决方案] 我通过在终端中实际运行git clone [repo url]而不是使用 Azure DevOps 的与 VSCode 接口的克隆按钮来消除此错误。

Navigate to this file => ios/Pods/RCT-Folly/folly/portability/Time.h导航到这个文件 => ios/Pods/RCT-Folly/folly/portability/Time.h

Comment this line => typedef uint8_t clockid_t;评论这一行 => typedef uint8_t clockid_t;

Change => _IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0 to _IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_12_0更改 => _IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0_IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_12_0

Updated Answer on June 2022 2022 年 6 月更新的答案

This can be achieved automatically by adding below line in your pod file under post_install这可以通过在 post_install 下的 pod 文件中添加以下行来自动实现

`sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`

I ran into the same issue with the same errors.我遇到了同样的错误和同样的问题。 The OS target version fix had already been applied by adding the script provided by RN to the Podfile like this:通过将 RN 提供的脚本添加到 Podfile 中,已经应用了 OS 目标版本修复,如下所示:

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

Perhaps this was automated in your RN version or template.也许这是在您的 RN 版本或模板中自动完成的。

I then found that the error然后我发现错误

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

actually came from that workaround script (in node_modules/react-native/scripts/react_native_pods.rb ), ie its sed -i -e … line, and I eventually figured that the script does not work and throws this error if your absolute path contains characters interpreted by the Shell (due to the path not being quoted properly in the script).实际上来自那个变通方法脚本(在node_modules/react-native/scripts/react_native_pods.rb ),即它的sed -i -e …行,我最终认为脚本不起作用,如果你的绝对路径包含Shell 解释的字符(由于脚本中没有正确引用路径)。

In my case the absolute path contained parentheses , seems yours also did at the time: …/ReactExplorerApp(Android)/… .在我的情况下,绝对路径包含括号,您当时似乎也这样做了: …/ReactExplorerApp(Android)/…

Solutions I can think of:我能想到的解决方案:

  1. Adjust your path to not contain parantheses (simplest solution)调整您的路径以不包含括号(最简单的解决方案)
  2. run sed manually, like suggested by @avinash-kannan手动运行sed就像@avinash-kannan 建议的那样
  3. fix the shell line in node_modules/react-native/scripts/react_native_pods.rb by adding single quotes around #{time_header} (not recommended as it might get overridden by yarn or npm)通过在#{time_header}周围添加单引号来修复node_modules/react-native/scripts/react_native_pods.rb中的 shell 行(不推荐,因为它可能会被 yarn 或 npm 覆盖)

I had the same issue with React native 0.70我对 React native 0.70 有同样的问题

System MacBook Pro (13-inch, M1, 2020) Apple M1系统 MacBook Pro(13 英寸,M1,2020)Apple M1

I followi the setup https://reactnative.dev/docs/environment-setup我按照设置https://reactnative.dev/docs/environment-setup

brew install node
-brew install watchman
sudo arch -x86_64 gem install ffi

Solved -- What was causing the issue was my project parent dir has a "space" in it, after creating a new directory in the root (with no spaces) and "npx react-native init app" the app finally builds解决- 导致问题的原因是我的项目父目录中有一个“空格”,在根目录(没有空格)和“npx react-native init app”创建了一个新目录之后,应用程序最终构建

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 关闭翻转器并仍然使用不同类型('uint8_t'(又名'unsigned char')与'enum clockid_t')重新定义Typedef - Turned flipper off and still getting Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t') react-native 无法构建 ios:(错误 xcode 翻转器)使用不同类型的 Typedef 重新定义('uint8_t'(又名'unsigned 'enum char')与 - react-native can't build ios: (error xcode Flipper) Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t') iOS Build错误“使用不同类型(&#39;NSUInteger&#39;(又名&#39;unsigned long&#39;)对&#39;ennum MTLPixelFormat&#39;)进行不同类型的Typedef重新定义” - iOS Build Error “Typedef redefinition with different types ('NSUInteger' (aka 'unsigned long') vs 'enum MTLPixelFormat')” M1 Mac react-native iOS 构建错误(在项目“Pods”的目标“RCT-Folly”中) - M1 Mac react-native iOS build error (in target 'RCT-Folly' from project 'Pods') React Native:RCT-Folly 致命错误 - 找不到“fmt/compile.h”文件 - React Native: RCT-Folly fatal error - 'fmt/compile.h' file not found 将 hermes 与 iOS 一起使用时出现 RCT-Folly 错误 - RCT-Folly error when using hermes with iOS 从不兼容的类型&#39;void *&#39;分配&#39;uint8_t *&#39;(又名&#39;unsigned char *&#39;) - assigning to 'uint8_t *' (aka 'unsigned char *' ) from incompatible type 'void *' React-Native 新的 ios 项目未构建。 RCT-Folly 语义问题 - React-Native new ios project not building. RCT-Folly Semantic issues 使用不同类型(“ signed char”和“ bool”)重新定义Typedef - Typedef redefinition with different types ('signed char' vs 'bool') &#39;folly/Portability.h&#39; 文件未找到 React 库 - 'folly/Portability.h' file not found React library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM