react-native: Unable to build release version for iOS with the new architecture

Description

I am unable to build release version for iOS with the new architecture. But I can build the debug version.

Here is build error

Undefined symbols for architecture x86_64:
  "folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::deferredReaders", referenced from:
      void folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::applyDeferredReaders<folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::WaitForever>(unsigned int&, folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::WaitForever&) in AppDelegate.o
      void folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::applyDeferredReaders<folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::WaitForever>(unsigned int&, folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::WaitForever&, unsigned int) in AppDelegate.o
  "folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::unlock()", referenced from:
      std::__1::unique_lock<folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false> >::~unique_lock() in AppDelegate.o
  "folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::~SharedMutexImpl()", referenced from:
      std::__1::__shared_ptr_emplace<facebook::react::ContextContainer const, std::__1::allocator<facebook::react::ContextContainer const> >::__on_zero_shared() in AppDelegate.o
ld: symbol(s) not found for architecture x86_64

Version

0.68.1

Output of npx react-native info

info Fetching system and libraries information...
System:
    OS: macOS 12.3.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 749.82 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.0.0 - ~/.nvm/versions/node/v18.0.0/bin/node
    Yarn: 1.22.18 - ~/.nvm/versions/node/v18.0.0/bin/yarn
    npm: 8.6.0 - ~/.nvm/versions/node/v18.0.0/bin/npm
    Watchman: 2022.03.21.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/wood/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.1 AI-211.7628.21.2111.8309675
    Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.15 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.68.1 => 0.68.1
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  1. npx react-native init AwesomeTSProject --template react-native-template-typescript
  2. Run RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
  3. npx react-native run-ios --configuration Release

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

Undefined symbols for architecture x86_64:
  "folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::deferredReaders", referenced from:
      void folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::applyDeferredReaders<folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::WaitForever>(unsigned int&, folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::WaitForever&) in AppDelegate.o
      void folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::applyDeferredReaders<folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::WaitForever>(unsigned int&, folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::WaitForever&, unsigned int) in AppDelegate.o
  "folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::unlock()", referenced from:
      std::__1::unique_lock<folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false> >::~unique_lock() in AppDelegate.o
  "folly::SharedMutexImpl<false, void, std::__1::atomic, false, false, false>::~SharedMutexImpl()", referenced from:
      std::__1::__shared_ptr_emplace<facebook::react::ContextContainer const, std::__1::allocator<facebook::react::ContextContainer const> >::__on_zero_shared() in AppDelegate.o
ld: symbol(s) not found for architecture x86_64

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 19 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Is building release without flipper the best practice?

Flipper should never be in the release app but it should be done via compilation flags instead of commenting out Podfile. Check out the template app which already does a good job of stripping out Flipper when not in DEBUG.

Is building release without flipper the best practice?

Flipper should never be in the release app but it should be done via compilation flags instead of commenting out Podfile. Check out the template app which already does a good job of stripping out Flipper when not in DEBUG.

👍🏻 I totally agree. I’ve tried to simplify the Flipper configuration, by bringing it into use_react_native, similarly to what we do for Fabric and Hermes, and I’ve used the flag production that is already available there to decide if add or not Flipper. That should solve this issue (even if is just a workaround), because if pod install is executed with production true, it won’t add the Flipper Pods at all (differently to what CocoaPods does currently, that adds it, but doesn’t copy it after is built), so Flipper won’t be compiled and won’t generate the mentioned error. I’m not fully familiar with this, so any feedback is welcome 😃 https://github.com/facebook/react-native/pull/33882

This issue persists both in RN 0.68.x and 0.69 when trying to build release version or to make an archive.

I’m facing it when building for MacCatalyst on M1.

You may add these lines to the end of post_install do |installer| as a temporary solution:

rm -f Pods/Flipper-Folly/folly/SharedMutex.cpp Pods/Flipper-Folly/folly/SharedMutex.h cp Pods/RCT-Folly/folly/SharedMutex.cpp Pods/Flipper-Folly/folly/ cp Pods/RCT-Folly/folly/SharedMutex.h Pods/Flipper-Folly/folly/

@stefanradu1989 you need to reinstall the pods with PRODUCTION=1 pod install

I found it