Skip to content

Unable to build release version for iOS with the new architecture #33764

Closed

Description

@wood1986

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

Activity

  1. tj-mc commented on May 6, 2022

    @tj-mc

    Followed steps but unable to reproduce on M1 Pro

  2. wood1986 commented on May 6, 2022

    @wood1986
    ContributorAuthor

    I missed the step. But did you RCT_NEW_ARCH_ENABLED=1 bundle exec pod install?

  3. Arkkeeper commented on May 15, 2022

    @Arkkeeper
    Contributor

    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/

  4. fabOnReact commented on May 15, 2022

    @fabOnReact
    Contributor
  5. cipolleschi commented on May 18, 2022

    @cipolleschi
    Contributor

    Hi @wood1986, thanks for the issue. Is the issue solved with the #33167 linked by @fabriziobertoglio1987 or is it still there?

  6. cortinico commented on May 18, 2022

    @cortinico
    Contributor

    Hi @wood1986, thanks for the issue. Is the issue solved with the #33167 linked by @fabriziobertoglio1987 or is it still there?

    @cipolleschi Nope I don't think the linked PR is relevant here. Such PR was fixing a build failure on Android, while the user is reporting an issue on iOS

  7. fabOnReact commented on May 18, 2022

    @fabOnReact
    Contributor

    sorry. I don't know the solution to this issue. I just included links to relevant conversations, which would help me find a solution. What I did find out is the following:

    Similar issue was experienced in the past. The symbol error was previously caused by folly depending on libc++abi
    8b6d7fd

    seems that https://stackoverflow.com/a/33686591/7295772 different environment use different libraries

    https://gcc.gnu.org/onlinedocs/gcc-11.3.0/libstdc++/api/a00176_source.html
    8b6d7fd#diff-5de3520951eb222bc3b5b734cc1003e84a53fb42220159fedc58768bda2e2cf3R75

    this are the folly releases https://github.com/facebook/folly/releases. I did not find anything relevant in the new releases.

    @Arkkeeper understand this issue and he tested this 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/
    

    so seems that the issue is caused by the Flipper-Folly SharedMutex , while it works with RCT-Folly SharedMutex

    this are the configs for folly futures in Flipper-Folly
    https://github.com/facebook/flipper/blob/0f038218f893d86e91714cd91eed8e37d756386c/iOS/Podspecs/Flipper-Folly.podspec#L74

    this are the configs for folly-futures in RCT-Folly
    https://github.com/facebook/react-native/blob/main/third-party-podspecs/RCT-Folly.podspec#L106-L148

    I'm not sure that this is connected to futures
    The above PR fixed the issue in folly futures, https://github.com/facebook/folly/blob/b72a70a35ada45ac286eb60028c0ecf5f6725665/folly/SharedMutex.h#L554-L571 as the undefined reference was unlock_shared

    This is an explanation of unlock_shared, deferredReaders seems to be an array of readers used to access data

    https://github.com/facebook/folly/blob/69b6f947ea9aeb73235ccabf235a6804e0f54946/folly/SharedMutex.h#L128-L161

    in this case the undefined symbol is folly::SharedMutexImpl<..>::deferredReaders

    It's 22:35 here and I have to go to sleep. Sorry for my incomplete message. 🙏
    I'll come back to this post in the future. Thanks.

  8. wood1986 commented on May 20, 2022

    @wood1986
    ContributorAuthor

    I have a question for you guys.

    Doing this does not make sense

    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/

    If I comment out use_flipper!() in the Podfile, I can build release successfully. Is building release without flipper the best practice?

  9. 6 remaining items

  10. leotm commented on Jul 20, 2022

    @leotm
    Contributor

    no longer getting the original issue with PRODUCTION= 1 pod install after updating Podfile, updated our template here too

    but had Flipper downgrade to 0.125.0, just thinking the best way to config Flipper again for a custom/latest version

    similar scenario will surface here
    https://github.com/facebook/flipper/blob/main/react-native/ReactNativeFlipperExample/ios/Podfile
    but not yet being on 0.67.4

    maybe better opened as seperate/follow-up issue

  11. wood1986 commented on Jul 24, 2022

    @wood1986
    ContributorAuthor

    How to specify the flipper version in 0.69.2?

  12. wood1986 commented on Jul 24, 2022

    @wood1986
    ContributorAuthor

    I found it

  13. leotm commented on Aug 3, 2022

    @leotm
    Contributor

    just for anyone else landing here

    https://github.com/facebook/react-native/blob/463af237539b98289c88e5b491c85cbf53bcaf0c/scripts/cocoapods/flipper.rb#L105

    nicely shows how to set custom Flipper version, we were unsure about at first

    so it could be worth us expanding on the comment here or adding an example for others in the future

    https://github.com/facebook/react-native/blob/463af237539b98289c88e5b491c85cbf53bcaf0c/template/ios/Podfile#L20

    will do pronto unless somebody (feel free) beats me to it :)

  14. added a commit that references this issue on Aug 5, 2022
  15. stefanradu1989 commented on Nov 16, 2022

    @stefanradu1989

    Hi,
    I get this error but only when I try to archive the project so I can upload to TestFlight.
    My use flipper is commented in my Podfile. (# use_flipper!())
    I am running RN 0.70 Xcode 14.1

    I tried the solution but it does not work:

    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/

    Did anyone solve this issue?

    PS: react native info
    System:
    OS: macOS 13.0.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 55.41 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
    Binaries:
    Node: 18.9.0 - /usr/local/bin/node
    Yarn: Not Found
    npm: 8.19.1 - /usr/local/bin/npm
    Watchman: 2022.09.05.00 - /opt/homebrew/bin/watchman
    Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
    SDKs:
    iOS SDK:
    Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
    IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
    Languages:
    Java: 11.0.16.1 - /usr/bin/javac
    npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0
    react-native: 0.70.4 => 0.70.4
    react-native-macos: Not Found
    npmGlobalPackages:
    react-native: Not Found

  16. cipolleschi commented on Nov 16, 2022

    @cipolleschi
    Contributor

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

  17. stefanradu1989 commented on Nov 17, 2022

    @stefanradu1989

    @cipolleschi thank you that solved my issue

  18. MJ0826 commented on Apr 25, 2023

    @MJ0826

    Hi,
    I'm not sure if this is related to the same stuff being talked about here, but I am struggling with building the app while updating from react-native version 0.67.4 to 0.69.9. Does anyone have any idea what can be the reason behind this ?

    Here are the screenShots -
    Screenshot 2023-04-25 at 9 48 27 PM
    Screenshot 2023-04-25 at 9 48 39 PM

  19. cipolleschi commented on Apr 28, 2023

    @cipolleschi
    Contributor

    @MJ0826 Can you walk throught what you did?

    To me, it looks like you just run yarn update react-native or something similar, but you forget to run pod install to update the dependencies.

    One thing that we did was to remove folly::Optional and replace it with std::optional, which seems the error that you are encountering. This should go away by reinstalling cocoapods with:

    # from your root folder
    cd ios
    bundle install
    bundle exec pod install
    

    Secondly, this issue is about the New Architecture. Are you building for the New Arch or for the Legacy one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions