![](/img/trans.png)
[英]Turned flipper off and still getting Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs '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')
我正在查看 react native 项目的源代码,但在构建它时遇到了问题。
运行以下命令后
npm install
在项目根目录下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'
当我使用 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、节点版本 14.17.2 和 XCode 版本 13.1
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
我尝试了许多类似问题的解决方案,但没有奏效。 我尝试通过在 podfile 中将其注释掉来禁用 Flipper,我还尝试将目标更改为 iOS 12。我还尝试在删除 podfile.lock 并运行pod install --repo-update
后安装 pod,我还运行了pod cache clean --all
我也在这里尝试了解决方案https://github.com/facebook/react-native/issues/31480 for "react-native": "0.64.1" // or higher
,但它对我和我都不起作用如果仍然有错误,我不清楚他们用“从 podfile.lock 中删除相关行”指的是什么。
编辑:[解决方案] 我通过在终端中实际运行
git clone [repo url]
而不是使用 Azure DevOps 的与 VSCode 接口的克隆按钮来消除此错误。
导航到这个文件 => 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
`sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
我遇到了同样的错误和同样的问题。 通过将 RN 提供的脚本添加到 Podfile 中,已经应用了 OS 目标版本修复,如下所示:
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)/…
。
我能想到的解决方案:
sed
,就像@avinash-kannan 建议的那样#{time_header}
周围添加单引号来修复node_modules/react-native/scripts/react_native_pods.rb
中的 shell 行(不推荐,因为它可能会被 yarn 或 npm 覆盖)我对 React native 0.70 有同样的问题
系统 MacBook Pro(13 英寸,M1,2020)Apple M1
我按照设置https://reactnative.dev/docs/environment-setup
brew install node
-brew install watchman
sudo arch -x86_64 gem install ffi
已解决- 导致问题的原因是我的项目父目录中有一个“空格”,在根目录(没有空格)和“npx react-native init app”创建了一个新目录之后,应用程序最终构建
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.