首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不同类型(“uint8_t”(又名“无符号字符”)与“enum clockid_t”)的Pods/RCT/folly/portability/Time.h和types重新定义中的错误

不同类型(“uint8_t”(又名“无符号字符”)与“enum clockid_t”)的Pods/RCT/folly/portability/Time.h和types重新定义中的错误
EN

Stack Overflow用户
提问于 2021-12-15 02:14:54
回答 3查看 5.1K关注 0票数 9

我正在审查react本机项目的源代码,但我在构建它时遇到了问题。

在运行以下命令之后

  1. 位于项目根目录的npm install
  2. ios文件夹下的pod install

我在终点站收到了以下消息:

代码语言:javascript
运行
复制
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'

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

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

这个应用程序使用的是“react原生”:"0.66.1“。我使用cocoapods版本1.11.2、节点版本14.17.2和XCode版本13.1

Podfile内容:

代码语言:javascript
运行
复制
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

对于类似的问题,我尝试了很多解决方案,但都没有奏效。我尝试通过在podfile中注释掉Flipper来禁用Flipper,我还尝试将目标更改为iOS 12。

我在这里也尝试了https://github.com/facebook/react-native/issues/31480 for "react-native": "0.64.1" // or higher的解决方案,但是它对我来说不起作用,如果仍然存在错误,我也不清楚它们指的是什么“从podfile.lock中删除相关的行”。

编辑:解决方案--我通过在我的终端中实际运行git clone [repo url]来消除这个错误,而不是使用Azure与VSCode接口的Clone按钮。

EN

回答 3

Stack Overflow用户

发布于 2022-02-04 13:30:46

导航到此文件=> 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文件中添加下面一行来实现。

代码语言:javascript
运行
复制
`sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
票数 5
EN

Stack Overflow用户

发布于 2022-07-20 14:28:07

我遇到了同样的问题,同样的错误。通过将RN提供的脚本添加到Podfile中,已经应用了OS目标版本修复,如下所示:

代码语言:javascript
运行
复制
  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

在RN版本或模板中,这可能是自动化的。

然后我发现这个错误

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

实际上来自于这个变通脚本(在node_modules/react-native/scripts/react_native_pods.rb中),即它的sed -i -e …行,我最终发现脚本不工作,如果您的绝对路径包含由Shell解释的字符(因为脚本中没有正确引用路径),那么我就会抛出这个错误。

在我的例子中绝对路径包含圆括号,似乎您当时也做了:…/ReactExplorerApp(Android)/…

我能想到的解决办法:

  1. 调整路径,使其不包含副项(最简单的解决方案)
  2. 手动运行sed就像@avinash-kannan建议的那样
  3. 通过在node_modules/react-native/scripts/react_native_pods.rb周围添加单引号来修复#{time_header}中的外壳线(不推荐,因为它可能被纱线或npm覆盖)
票数 1
EN

Stack Overflow用户

发布于 2022-09-23 14:13:57

我也有同样的问题,反应本机0.70

System MacBook Pro (13英寸,M1,2020) Apple M1

我遵循设置https://reactnative.dev/docs/environment-setup

代码语言:javascript
运行
复制
brew install node
-brew install watchman
sudo arch -x86_64 gem install ffi

解决了 --导致这个问题的是我的项目父dir在根目录中创建了一个“空格”(没有空格)和“native本机init应用程序”之后,这个应用程序最终构建了一个“空格”。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70357696

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档