在 IOS 上反应本机构建错误 - 使用不同类型的 typedef 重新定义('uint8_t'(又名'unsigned char')与'enum clockid_t')

pic*_*ode 12 flipper react-native react-native-ios

将 React Native 从 0.61.5 升级到 0.63.2 后,Flipper在 IOS 上导致错误为typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

在 github 上有一些建议的答案,但没有一个解决了我的问题https://github.com/facebook/flipper/issues/834

有没有人想出如何解决这个问题?

非常感谢

sul*_*lam 11

步骤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
Run Code Online (Sandbox Code Playgroud)

第2步:

在第 1 步之后,您必须在路径pod update上运行命令YOUR_PROJECT > ios

宾果游戏完成了。


重要的

如果执行上述 2 个步骤后出现一些错误,

  1. 转到YOUR_PROJECT > ios > YOUR_PROJECT_NAME >并运行此命令
  2. plutil ./Info.plist它会告诉你问题出在哪里。
  3. 然后从文本编辑器解决该问题。

  • 这应该接受答案!拯救我的一天 (3认同)

小智 9

请注意,如果您有 use_frameworks! 启用后,Flipper 将无法工作,您应该在 Podfile 中禁用接下来的几行。

  # use_flipper!
  # post_install do |installer|
  #   flipper_post_install(installer)
  # end
Run Code Online (Sandbox Code Playgroud)

  • 确保之后再次运行 pod update,否则构建仍然会失败 (5认同)

小智 8

目录名称不应包含项目存在的空间。这也可能导致此错误。


Sid*_*ant 6

这就是我为 React Native 0.65 解决的问题。非常重要的是愚蠢应该链接到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
Run Code Online (Sandbox Code Playgroud)


小智 6

首先,从项目中删除 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
Run Code Online (Sandbox Code Playgroud)

之后,请尝试通过 Xcode 运行应用程序,现在应用程序无法成功运行,您收到另一个错误

第二个错误是:“命令 PhaseScriptExecution 失败,退出代码非零”

屏幕截图中的第二个错误解决方案,

在此输入图像描述