[英]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运行以下命令后
npm install
at the root of the project npm install
在项目根目录下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
`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:我能想到的解决方案:
sed
manually, like suggested by @avinash-kannansed
,就像@avinash-kannan 建议的那样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.