我正在审查react本机项目的源代码,但我在构建它时遇到了问题。
在运行以下命令之后
npm install
pod install
我在终点站收到了以下消息:
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内容:
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按钮。
发布于 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文件中添加下面一行来实现。
`sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
发布于 2022-07-20 14:28:07
我遇到了同样的问题,同样的错误。通过将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建议的那样node_modules/react-native/scripts/react_native_pods.rb
周围添加单引号来修复#{time_header}
中的外壳线(不推荐,因为它可能被纱线或npm覆盖)发布于 2022-09-23 14:13:57
我也有同样的问题,反应本机0.70
System 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
解决了 --导致这个问题的是我的项目父dir在根目录中创建了一个“空格”(没有空格)和“native本机init应用程序”之后,这个应用程序最终构建了一个“空格”。
https://stackoverflow.com/questions/70357696
复制相似问题