typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')
。在Github上有一些提议的解决方法,但是没有一个能够解决我的问题。https://github.com/facebook/flipper/issues/834。是否有人找到了解决方法?非常感谢。typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')
。在Github上有一些提议的解决方法,但是没有一个能够解决我的问题。https://github.com/facebook/flipper/issues/834。是否有人找到了解决方法?非常感谢。 # use_flipper!
# post_install do |installer|
# flipper_post_install(installer)
# end
步骤1:
进入YOUR_PROJECT > ios > Podfile
,然后注释掉以下几行代码:
# use_flipper!()
# post_install do |installer|
# react_native_post_install(installer)
# __apply_Xcode_12_5_M1_post_install_workaround(installer)
# end
步骤2:
在完成步骤1后,您需要在YOUR_PROJECT > ios
路径下运行 pod update
命令。
Bingo就完成了。
重要提示:
如果您在完成上述两个步骤后遇到一些错误,请执行以下步骤:
YOUR_PROJECT > ios > YOUR_PROJECT_NAME >
并运行以下命令plutil ./Info.plist
它将向您显示问题所在位置。react_native_post_install(installer)
部分。 - xji项目所在的目录名称不应包含空格。否则会导致此错误。
这是我针对React Native 0.65的解决方法。非常重要的是,folly 应链接到 9.0 版本。
post_install do |installer|
react_native_post_install(installer)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete "IPHONEOS_DEPLOYMENT_TARGET"
end
case target.name
when 'RCT-Folly'
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
end
首先,从您的项目中删除Flipper。
接下来,按照以下路径进行操作: 路径:"Your-Project-App/ios/Pods/RCT-Folly/folly/portability/Time.h"
将该代码替换为time.h。
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <stdint.h>
#include <time.h>
#include <folly/portability/Config.h>
// OSX is a pain. The XCode 8 SDK always declares clock_gettime
// even if the target OS version doesn't support it, so you get
// an error at runtime because it can't resolve the symbol. We
// solve that by pretending we have it here in the header and
// then enable our implementation on the source side so that
// gets linked in instead.
#if __MACH__ && \
((!defined(TARGET_OS_OSX) || TARGET_OS_OSX) && \
(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12)) || \
(TARGET_OS_IPHONE)
#ifdef FOLLY_HAVE_CLOCK_GETTIME
#undef FOLLY_HAVE_CLOCK_GETTIME
#endif
#define FOLLY_HAVE_CLOCK_GETTIME 1
#define FOLLY_FORCE_CLOCK_GETTIME_DEFINITION 1
#endif
// These aren't generic implementations, so we can only declare them on
// platforms we support.
#if !FOLLY_HAVE_CLOCK_GETTIME && (defined(__MACH__) || defined(_WIN32))
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 1
#define CLOCK_PROCESS_CPUTIME_ID 2
#define CLOCK_THREAD_CPUTIME_ID 3
typedef uint8_t clockid_t;
extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts);
extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts);
#endif
#ifdef _WIN32
#define TM_YEAR_BASE (1900)
extern "C" {
char* asctime_r(const tm* tm, char* buf);
char* ctime_r(const time_t* t, char* buf);
tm* gmtime_r(const time_t* t, tm* res);
tm* localtime_r(const time_t* t, tm* o);
int nanosleep(const struct timespec* request, struct timespec* remain);
char* strptime(
const char* __restrict buf,
const char* __restrict fmt,
struct tm* __restrict tm);
time_t timelocal(tm* tm);
time_t timegm(tm* tm);
}
#endif
在这之后,请尝试通过Xcode运行应用程序,现在该应用程序无法成功运行,您会得到另一个错误。
第二个错误是:"Command PhaseScriptExecution failed with a nonzero exit code"。
第二个错误的解决方法如截图所示:
请使用以下代码更新你的Pod文件。
use_flipper!({ 'Flipper-Folly' => '2.3.0' }) # update this part
post_install do |installer|
flipper_post_install(installer)
end
对我来说,这个错误是因为我在 ios/Podfile
中做了以下操作:
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
installer.pods_project.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
我只能假设将 "Folly" 目标的构建目标设置弄错了什么。一旦这些行从我的 Podfile 中删除,并运行 npx pod-install
,构建就又可以正常工作了。
我需要指定版本:
# https://github.com/facebook/flipper/releases
# https://cocoapods.org/pods/Flipper-Folly
# https://cocoapods.org/pods/OpenSSL-Universal
use_flipper!({
"Flipper" => "0.134.0",
"Flipper-Folly" => "2.6.10",
"OpenSSL-Universal" => "1.1.1100"
})
对于完整的Podfile,这可能会有所帮助:
require_relative "../node_modules/expo/scripts/autolinking"
require_relative "../node_modules/react-native/scripts/react_native_pods"
require_relative "../node_modules/@react-native-community/cli-platform-ios/native_modules"
platform :ios, "12.0"
target "socializus" do
use_expo_modules!
config = use_native_modules!
use_react_native!(
path: config[:reactNativePath],
hermes_enabled: false
)
# https://github.com/facebook/flipper/releases
# https://cocoapods.org/pods/Flipper-Folly
# https://cocoapods.org/pods/OpenSSL-Universal
use_flipper!({
"Flipper" => "0.134.0",
"Flipper-Folly" => "2.6.10",
"OpenSSL-Universal" => "1.1.1100"
})
post_install do |installer|
flipper_post_install(installer)
react_native_post_install(installer)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete "IPHONEOS_DEPLOYMENT_TARGET"
end
end
end
end
我曾遇到与 RCT-Folly
相关的问题,并通过以下方法解决了它:
基本上,问题出在文件 ../node_modules/react-native/scripts/react_native_pods.rb
中。这是该文件的代码。
# But... doing so caused another issue in Flipper:
# "Time.h:52:17: error: typedef redefinition with different types"
# We need to make a patch to RCT-Folly - remove the `__IPHONE_OS_VERSION_MIN_REQUIRED` check.
# See https://github.com/facebook/flipper/issues/834 for more details.
time_header = "#{Pod::Config.instance.installation_root.to_s}/Pods/RCT-Folly/folly/portability/Time.h"
`sed -i -e $'s/ && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0)//' #{time_header}`
node_modules
中的代码,.lock
文件将会被更改。因此为了安全起见,你可以更新Podfile
。Podfile
的post_install do |installer|
行后添加以下代码段,如下所示:
添加以下代码行
sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h
target 'AwesomeProjectTests' 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_flipper!()
post_install do |installer|
`sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
在项目的根目录下运行 cd ios
在终端中运行 pod deintegrate
命令,然后再使用命令 pod install
重新安装Pod
最后,在项目的根目录下运行命令 npx react-native run-ios
再次构建项目
太棒了!我的问题已经得到了解决。
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
- Rajeev Kumar Verma