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
- npx react-native init AwesomeTSProject --template react-native-template-typescript
- Run RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
- 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
- Move `use_flipper` logic inside `use_react_native` and simplify the Flipper dependencies logic (#33882) Summary: This PR tries to simplify the `use_flipper` logic: - makes `use_flipper` a configurati... — committed to facebook/react-native by f-meloni 2 years ago
- [deploy-ios] fix: 디버그 빌드에서만 flipper 사용하도록 - 빌드 오류 수정 - https://github.com/facebook/react-native/issues/33764 — committed to jiggag/react-native-starter by jiggag 2 years ago
- [deploy-ios] fix: 디버그 빌드에서만 flipper 사용하도록 - 빌드 오류 수정 - https://github.com/facebook/react-native/issues/33764 — committed to jiggag/react-native-starter by jiggag 2 years ago
- [deploy-ios] fix: 디버그 빌드에서만 flipper 사용하도록 - 빌드 오류 수정 - https://github.com/facebook/react-native/issues/33764 — committed to jiggag/react-native-starter by jiggag 2 years ago
- Fix prod build error w Flipper, set env flag Issue - https://github.com/reactwg/react-native-releases/discussions/21#discussioncomment-2941715 - https://github.com/facebook/react-native/issues/3376... — committed to leotm/react-native-template-new-architecture by leotm 2 years ago
- Update Podfile for `PRODUCTION=1 pod install` (#34234) Summary: ### Mentioned - pr[main]: https://github.com/facebook/react-native/pull/33882 - discussion: https://github.com/reactwg/react-native-rel... — committed to facebook/react-native by leotm 2 years ago
- iOS CI Release on `macos-12` (#690) * Draft ios.yml * Fix indentation * Update ios.yml * Build app for release * Fix prod build error w Flipper, set env flag Issue - https://github.co... — committed to leotm/react-native-template-new-architecture by leotm 2 years ago
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 inDEBUG
.👍🏻 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 flagproduction
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 withproduction
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/33882This 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