Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCT-Folly/folly/portability/Time.h:52:17: typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t') #32483

Closed
Tracked by #17361
nicolascavallin opened this issue Oct 27, 2021 · 23 comments
Labels
Needs: Attention Issues where the author has responded to feedback.

Comments

@nicolascavallin
Copy link

nicolascavallin commented Oct 27, 2021

Description

Some days ago with my team we've decided to upgrade to RN 0.66.1

After that, I never again can run the project in device or simulator.

I always got the same error:

~/AwesomeProject/ios/Pods/Headers/Private/RCT-Folly/folly/portability/Time.h:52:17:` typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum `clockid_t')

But the strange situation is the rest of my team can run and build for device and simulator.

I tried EVERYTHING. Even reinstall Xcode, full cache clean, and all the possible solutions that I've found on web.

The last thing I'm thinking of is reinstall macOS and setup my environment from zero.

Version

0.66.1

Output of react-native info

System:
OS: macOS 11.6
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Memory: 83.00 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 17.0.1 - /var/folders/xg/t7smqnln18bgm1n6f4svxlph0000gn/T/yarn--1635338087075-0.4760779983126484/node
Yarn: 1.22.17 - /var/folders/xg/t7smqnln18bgm1n6f4svxlph0000gn/T/yarn--1635338087075-0.4760779983126484/yarn
npm: 8.1.0 - /usr/local/bin/npm
Watchman: 2021.10.18.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
Android SDK: Not Found
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.7199119
Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
Languages:
Java: 11.0.11 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.1 => 0.66.1
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

  1. I created a new RN project (following https://reactnative.dev).
  2. I run react-native run-ios.
  3. I got always the same error.
~/AwesomeProject/ios/Pods/Headers/Private/RCT-Folly/folly/portability/Time.h:52:17:` typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum `clockid_t')

Snack, code example, screenshot, or link to a repository

No response

@react-native-bot react-native-bot added Needs: Author Feedback Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. and removed Needs: Triage 🔍 labels Oct 27, 2021
@github-actions

This comment has been minimized.

@arsalan-arshad
Copy link

I have same issue

@nicolascavallin
Copy link
Author

I didn't find a solution yet, I had to downgrade to RN 65

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Nov 2, 2021
@cortinico cortinico removed the Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. label Nov 2, 2021
@nataly87s
Copy link

nataly87s commented Nov 4, 2021

I have the same issue on both 0.66.1 and 0.65.1

@nicolascavallin
Copy link
Author

nicolascavallin commented Nov 4, 2021

Please, check your Podfile and be sure that the next piece of code is commented (add # in each line)

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

then run pod update in ios folder

@nataly87s
Copy link

@nicolascavallin I still get the same error
this is my podfile:

use_frameworks! :linkage => :static

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

use_modular_headers!
use_frameworks!

# Convert all permission pods into static libraries
pre_install do |installer|
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

  installer.pod_targets.each do |pod|
    if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
      def pod.build_type;
        # Uncomment the line corresponding to your CocoaPods version
        Pod::BuildType.static_library # >= 1.9
        # Pod::Target::BuildType.static_library # < 1.9
      end
    end
  end
end

# Use Firebase as a static framework, to allow building with frameworks
$RNFirebaseAsStaticFramework = true

source "https://cdn.cocoapods.org/"

pod 'SwiftKeychainWrapper'

platform :ios, '12.0'

target 'MyApp' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  permissions_path = '../../../node_modules/react-native-permissions/ios'

  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"

  target 'MyAppTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
#    react_native_post_install(installer)
#    __apply_Xcode_12_5_M1_post_install_workaround(installer)

    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      end
    end
  end
end

@nicolascavallin
Copy link
Author

@nicolascavallin I still get the same error this is my podfile:

use_frameworks! :linkage => :static

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

use_modular_headers!
use_frameworks!

# Convert all permission pods into static libraries
pre_install do |installer|
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

  installer.pod_targets.each do |pod|
    if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
      def pod.build_type;
        # Uncomment the line corresponding to your CocoaPods version
        Pod::BuildType.static_library # >= 1.9
        # Pod::Target::BuildType.static_library # < 1.9
      end
    end
  end
end

# Use Firebase as a static framework, to allow building with frameworks
$RNFirebaseAsStaticFramework = true

source "https://cdn.cocoapods.org/"

pod 'SwiftKeychainWrapper'

platform :ios, '12.0'

target 'MyApp' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  permissions_path = '../../../node_modules/react-native-permissions/ios'

  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"

  target 'MyAppTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
#    react_native_post_install(installer)
#    __apply_Xcode_12_5_M1_post_install_workaround(installer)

    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      end
    end
  end
end

Sorry but I didn’t found the solution yet. I just "hacked" using RN 65 in my local environment.

@nataly87s
Copy link

adding this to the pre-build script fixed the issue:

sed -i '' 's/__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_12_0/__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0/' "${SRCROOT}/Pods/RCT-Folly/folly/portability/Time.h"

@Perni1984
Copy link

@nataly87s we are facing the same problem here - could you elaborate where exactly you added this pre-build script? I am a react native newbee. Thanks!

@darrylyoung
Copy link

@Perni1984 Have a look at the comments in #31941. I had the following issue before making some changes to the workaround supplied in React Native 0.66. See this comment, for example.

@nataly87s
Copy link

@Perni1984 add it to your schema
https://robertharrison.ca/posts/2020-01-03-xcode-prebuild-script/

@namnd
Copy link

namnd commented Nov 12, 2021

Thanks @nataly87s , removing that line 52 in Time.h works for me.

sed -i '' 's/typedef uint8_t clockid_t;//' "${SRCROOT}/Pods/RCT-Folly/folly/portability/Time.h"

@arsalan-arshad
Copy link

@

I didn't find a solution yet, I had to downgrade to RN 65

I did it with RN 66
steps

  1. remove react-native-unmodules and setup expo-core-modules
  2. flow expo-core-modules step by step for changes in pod file and Appdelegate.M/H

@KrisLau
Copy link

KrisLau commented Apr 19, 2022

Still facing the same issue with upgrading React Native for months now. It's blocking the update of the other dependencies that depend on React Native being updated as well

@astrahov
Copy link

astrahov commented May 23, 2022

I found the pattern of this error! It's all about the path to the project.

// Init clear RN (0.68.2) project ...

/Volumes/development/sandbox/new folder/AwecomeProject/... Error!
/Volumes/development/sandbox/rn-0-68-2/AwecomeProject/... No Error, run successful

The error occurs when there are spaces in the path to the project!

@karatekid430
Copy link

React native 0.68.2 this issue is causing major problems

@KrisLau
Copy link

KrisLau commented Jul 14, 2022

@Hugyn
Copy link

Hugyn commented Sep 23, 2022

I had the same issue with React native 0.70

System
MacBook Pro (13-inch, M1, 2020)
Apple M1

I followi the 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

@nicolascavallin
Copy link
Author

I had the same issue with React native 0.70

System MacBook Pro (13-inch, M1, 2020) Apple M1

I followi the 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

Ooops, yes. Watchman crash if the folder has an space (at least in my experience).

By the way, in M1, RN works for me if I install pods and if I run react-native run-ios with the arch x86_64 prefix

@Lazybon
Copy link

Lazybon commented Apr 24, 2023

Hi! Try update RN to 66.5 and see migration guid, there are some changes in Podfile and AppDelegate file if needed. And try build your app in ios 14.4

@ahmetgsu
Copy link

I leave my comment for anyone who faced the same issue recently. I hope this may help
We recently upgraded the React native version from 0.67 to 0.72.3. At that time we removed __apply_Xcode_12_5_M1_post_install_workaround(installer) from the Podfile and nothing was broken.
When we upgraded it from 0.72.3 to 0.72.7, this error occurred and we added __apply_Xcode_12_5_M1_post_install_workaround(installer) in the Podfile and it solved the issue.

@EmpiteNishain
Copy link

@Perni1984 add it to your schema https://robertharrison.ca/posts/2020-01-03-xcode-prebuild-script/

the given link is broken, So anyway here is what worked for me

post_install do |installer| react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) "sed -i 's/typedef uint8_t clockid_t;//' ${SRCROOT}/Pods/RCT-Folly/folly/portability/Time.h" end

I was first confused with command sed is Unix utility to replace text on a given file. Note that // does not mean a comment, it indicates new text to replace with and since we replacing the text with nothing it looks like //

@csori99
Copy link

csori99 commented Aug 15, 2024

@Perni1984 add it to your schema https://robertharrison.ca/posts/2020-01-03-xcode-prebuild-script/

that worked for me, thanks

jchen351 added a commit to microsoft/onnxruntime that referenced this issue Sep 4, 2024
jchen351 added a commit to microsoft/onnxruntime that referenced this issue Sep 4, 2024
jchen351 added a commit to microsoft/onnxruntime that referenced this issue Sep 17, 2024
### Description
See microsoft/onnxruntime-extensions#476
and actions/runner-images#7671

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

### Current issue
- [ ] For default xcode 15.2, that come with the MacOS-13, We Need to
update the boost container header boost/container_hash/hash.hpp version
to pass the build
- [x] For xcode 14.2 The Build passed but the `Run React Native Detox
Android e2e Test` Failed.
Possible flaky test, #21969
- [x] For xcode 14.3.1 We encountered following issue in `Build React
Native Detox iOS e2e Tests`
```
ld: file not found: /Applications/Xcode_14.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
Applied following code to the eof in both ios/Podfile and fixed the
issue
```
post_install do |installer|
    installer.generated_projects.each do |project|
        project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
            end
        end
    end
end
```


- [x] facebook/react-native#32483

Applying changes to ios/Pofile
```
pre_install do |installer|
  # Custom pre-install script or commands
  puts "Running pre-install script..."

  # Recommended fix for facebook/react-native#32483
  # from facebook/react-native#32483 (comment)
  system("sed -i '' 's/typedef uint8_t clockid_t;//' \"${SRCROOT}/Pods/RCT-Folly/folly/portability/Time.h\"")
end
```

- [ ] Detox environment setting up exceeded time out of 120000ms during
iso e2e test


### dependent 

- [x] #21159

---------

Co-authored-by: Changming Sun <chasun@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention Issues where the author has responded to feedback.
Projects
None yet
Development

No branches or pull requests