Adriaan De Bolle
Adriaan De Bolle

Reputation: 255

RCT-Folly error when using hermes with iOS

When enabling hermes in the Podfile and rebuilding the build it fails due to RCT-Folly. No idea what it does.

To re-initialise everything I use the following:

rm -rf node_modules && rm package-lock.json && npm install && cd ios && rm -rf Pods && rm Podfile.lock && pod deintegrate && pod setup && pod install && cd ..

I also start the metro bundler with:

npx react-native --reset-cache

Anyone has a solution?

The app uses react-native v0.64 and we want to have a better performance using hermes.

All information:

ios/Podfile

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

target 'unblnd' do
  config = use_native_modules!
  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => true
  )

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral"
  pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars"
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts"
  pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID"
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways"
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
  pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary"
  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"
  pod 'Permission-Motion', :path => "#{permissions_path}/Motion"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
  pod 'Permission-Reminders', :path => "#{permissions_path}/Reminders"
  pod 'Permission-Siri', :path => "#{permissions_path}/Siri"
  pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition"
  pod 'Permission-StoreKit', :path => "#{permissions_path}/StoreKit"

  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true

  # add the Firebase pod for Google Analytics
  pod 'Firebase/Analytics'
  # add pods for any other desired Firebase products
  # https://firebase.google.com/docs/ios/setup#available-pods


  target 'unblndTests' 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 these next few lines.
  # flipper_pods()
  # post_install do |installer|
  #  flipper_post_install(installer)
  # end
end

Terminal Output

In file included from /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods/RCT-Folly/folly/synchronization/DistributedMutex.cpp:17: In file included from /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods/Headers/Private/RCT-Folly/folly/synchronization/DistributedMutex.h:352: /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods/Headers/Private/RCT-Folly/folly/synchronization/DistributedMutex-inl.h:1051:5: error: 'atomic_notify_one<unsigned long>' is unavailable
    atomic_notify_one(state);
    ^ /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods/Headers/Private/RCT-Folly/folly/synchronization/DistributedMutex-inl.h:1573:5: note: in instantiation of function template specialization 'folly::detail::distributed_mutex::wakeTimedWaiters<std::__1::atomic<unsigned long>>' requested here
    wakeTimedWaiters(&state_, proxy.timedWaiters_);
    ^ In file included from /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods/RCT-Folly/folly/synchronization/DistributedMutex.cpp:17: In file included from /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods/Headers/Private/RCT-Folly/folly/synchronization/DistributedMutex.h:19: In file included from /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods/Headers/Private/RCT-Folly/folly/Optional.h:58: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/c++/v1/functional:504: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/c++/v1/memory:681: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/c++/v1/atomic:2140:6: note: 'atomic_notify_one<unsigned long>' has been explicitly marked unavailable here void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT
     ^ 1 error generated.

CompileC /Users/adriaandebolle/Library/Developer/Xcode/DerivedData/unblnd-cvaavakypguqqzftojmgjqbtdeij/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/x86_64/Demangle-3c4c6b43c285d16c32230d6f0a7a76ce5af39228ed5c3beeaf7ed7d1344f76b0.o /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods/RCT-Folly/folly/detail/Demangle.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'RCT-Folly' from project 'Pods')

...

CompileC /Users/adriaandebolle/Library/Developer/Xcode/DerivedData/unblnd-cvaavakypguqqzftojmgjqbtdeij/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/x86_64/Cursor.o /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods/RCT-Folly/folly/io/Cursor.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'RCT-Folly' from project 'Pods')
    cd /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods
    export LANG\=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/

...

** BUILD FAILED **


The following build commands failed:    CompileC /Users/adriaandebolle/Library/Developer/Xcode/DerivedData/unblnd-cvaavakypguqqzftojmgjqbtdeij/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/x86_64/DistributedMutex.o /Users/adriaandebolle/htdocs/unblnd_app/ios/Pods/RCT-Folly/folly/synchronization/DistributedMutex.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (1 failure)

npx react-native info

System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Memory: 1.05 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.0 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.14.13 - ~/htdocs/unblnd_app/node_modules/.bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2
      System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7351085
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_265 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.2 => 0.64.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Upvotes: 5

Views: 31721

Answers (10)

Dan Wuensch
Dan Wuensch

Reputation: 132

XCode 15 introduced breaking changes to its C++ compiler that caused all kinds of havoc with the React Native iOS build process.

Upgrading to react-native 0.72.5 addressed this issue for me. React Native team indicated the fixes are coming to other lower versions as well soon including 0.70.

If upgrading is not an option, you may be able to work around this by adding the following to Podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
    end
  end
end

Upvotes: 1

faraz naeem
faraz naeem

Reputation: 121

It seems like you've changed the version of the dependency RCT-Folly somehow, it could happend when user try to copy podfile or dependencies from other existing project and it differs from the version stored in Pods/Local Podspecs. You should run pod update RCT-Folly --no-repo-update to apply changes made locally. if this is your case then try this command

pod update RCT-Folly --no-repo-update

Upvotes: 9

Relie Essom
Relie Essom

Reputation: 1384

Another solution is to run:

pod update && pod install

this should fix the issue.

Upvotes: 14

Lokesh
Lokesh

Reputation: 425

I have find one simple solution for react native project run on mac m1 chip. you are try multiple solution to run a project so some config change on your current project, so easy solve

  1. create new project npx react-native init Project_name. And do not run your project instantly
  2. To navigate to pod file comment # use_flipper!().
  3. pod install
  4. npx react-native run-ios

Upvotes: 0

Okpo
Okpo

Reputation: 417

I deleted Podfile.lock, then npx pod-install. That solved my problem

Upvotes: 2

Isuru
Isuru

Reputation: 31313

I'm on a 2020 M1 Apple MacBook and none of these solutions worked for me. The folder where I had the project created in was named 'React Native' with a space in-between. Apparently that had an adverse effect on running the pod install properly. I renamed the folder to 'React_Native' and ran pod install and everything started working.

Upvotes: 2

Varun Nath
Varun Nath

Reputation: 5632

What worked for me:

I'm using react native version 0.67.3 MacOS Monterey(Intel Mac)

1.Open the project in Xcode using the .xcworkspace file 2.Run the app from Xcode.

Seems to work without the error.

Upvotes: -3

Dragos UniqQum
Dragos UniqQum

Reputation: 665

The solution is to remove white spaces from project root folders.

See below:

Project/ReactNative/MySampleProj

Upvotes: 1

Pankaj bhalala
Pankaj bhalala

Reputation: 183

I faced some errors for this version { 'Flipper' => '0.87' }

So I have done some changes and this Podfile setup is working for me

use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })

  post_install do |installer|
    react_native_post_install(installer)
    flipper_post_install(installer)

     find_and_replace("Pods/Headers/Private/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
     "atomic_notify_one(state)", "folly::atomic_notify_one(state)")

     find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
     "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
  end
end

Upvotes: 1

Adriaan De Bolle
Adriaan De Bolle

Reputation: 255

After lots of trial and error I found a working solution. It's a bit strange, but I had to enable Flipper. I did not find a way without it.

Thanks to this answer: https://github.com/facebook/react-native/issues/31179#issuecomment-831932941 I found out about fixing Pods.

This is my Podfile now:

  ...

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!({ 'Flipper' => '0.87' })
  post_install do |installer|
    flipper_post_install(installer)

    find_and_replace("Pods/Headers/Private/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
    "atomic_notify_one(state)", "folly::atomic_notify_one(state)")

    find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
    "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
  end

  ...

Upvotes: 6

Related Questions