1

Trying to build react native app on ios(objective c) on RN version 0.66.4 and realm v 2.29.0.

The podfile has the Realm version 3.17.3

When trying to build, getting the following error:

  "realm::BpTreeBase::replace_root(std::__1::unique_ptr<realm::Array, std::__1::default_delete<realm::Array> >)", referenced from:
      realm::Column<long long>::replace_root_array(std::__1::unique_ptr<realm::Array, std::__1::default_delete<realm::Array> >) in libRealm.a(RLMCollection.o)
      realm::BpTree<long long>::EraseHandler::replace_root_by_leaf(realm::MemRef) in libRealm.a(RLMCollection.o)
      realm::BpTree<long long>::EraseHandler::replace_root_by_empty_leaf() in libRealm.a(RLMCollection.o)
      realm::BpTree<long long>::clear() in libRealm.a(RLMCollection.o)
      realm::Column<long long>::replace_root_array(std::__1::unique_ptr<realm::Array, std::__1::default_delete<realm::Array> >) in libRealm.a(RLMOptionalBase.o)
      realm::BpTree<long long>::EraseHandler::replace_root_by_leaf(realm::MemRef) in libRealm.a(RLMOptionalBase.o)
      realm::BpTree<long long>::EraseHandler::replace_root_by_empty_leaf() in libRealm.a(RLMOptionalBase.o)
      ...
  "realm::BpTreeBase::write_subtree(realm::BpTreeNode const&, unsigned long, unsigned long, unsigned long, realm::BpTreeBase::SliceHandler&, realm::_impl::OutputStream&)", referenced from:
      realm::BpTree<long long>::write(unsigned long, unsigned long, unsigned long, realm::_impl::OutputStream&) const in libRealm.a(RLMCollection.o)
      realm::BpTree<long long>::write(unsigned long, unsigned long, unsigned long, realm::_impl::OutputStream&) const in libRealm.a(RLMOptionalBase.o)
      realm::BpTree<long long>::write(unsigned long, unsigned long, unsigned long, realm::_impl::OutputStream&) const in libRealm.a(RLMAccessor.o)
      realm::BpTree<long long>::write(unsigned long, unsigned long, unsigned long, realm::_impl::OutputStream&) const in libRealm.a(sync_permission.o)
      realm::BpTree<long long>::write(unsigned long, unsigned long, unsigned long, realm::_impl::OutputStream&) const in libRealm.a(object_store.o)
      realm::BpTree<long long>::write(unsigned long, unsigned long, unsigned long, realm::_impl::OutputStream&) const in libRealm.a(partial_sync.o)
      realm::BpTree<long long>::write(unsigned long, unsigned long, unsigned long, realm::_impl::OutputStream&) const in libRealm.a(results.o)
      ...

There are lot of other similar errors of realm. Realm errors

I tried

rm -rf ~/Library/Caches/CocoaPods
pod cache clean Realm
pod deintegrate || rm -rf Pods
pod install --verbose
rm -rf ~/Library/Developer/Xcode/DerivedData

but this didn't help me.

podfile:

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

platform :ios, '11.0'

target 'Ajjas' do
  config = use_native_modules!
  use_modular_headers!

  # Pods for Ajjas

  pod 'Realm', '3.17.3',:modular_headers => true
  pod 'Avro-C', '1.7.6'
  pod 'GoogleMaps', '3.7.0'
  pod 'SocketRocket', '0.5.1'
  pod 'IQKeyboardManager'
  pod 'FirebaseCrashlytics' # , '4.3.0'
  pod 'FirebaseAnalytics' #, '6.6.2'
  pod 'Fabric', '~> 1.10'

  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false

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

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  # use_flipper!()
    # post_install do |installer|
    # 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|
    #   if target.name == 'React'
    #     target.remove_from_project
    #   end
    # end
  end
end

I am not sure is this a version problem, because this was working with older react-native version(0.60.5) (didn't give a try between 0.60.5 and 0.66.4 versions and directly jumped to 0.66.4)

Using xcode version 13.4.1 on MacBook M1.

Any help on how to solve this problem will be much appreciated!

Saif Ali Khan
  • 818
  • 3
  • 9
  • 34
  • What ruby are you using? – matt Jun 30 '22 at 18:32
  • @matt ruby version `ruby 2.6.8p205` – Saif Ali Khan Jun 30 '22 at 19:00
  • 1
    Right but is it the built-in ruby? Because if so, step one would be stop using that. The `cocoapods` gem (and all other gems) need to be in a user-installed ruby. If you have to say `sudo` to install gems, you're using the wrong ruby. – matt Jun 30 '22 at 19:26
  • @matt, yes I believe it's the build-in ruby (`ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86_64-darwin21]`) , will this be causing this issue of the realm? The reason is, that it was working fine earlier with the older react-native version. – Saif Ali Khan Jun 30 '22 at 19:30
  • I don't know if it's the cause but it needs to be fixed so you might as well do that. – matt Jun 30 '22 at 19:37
  • I just added ruby using `brew`, removed existing pods, run `pod install` again, and cleaned the build folder, but still having the same issue. :( @matt Do you want some other or additional information to better understand how can this be solved? – Saif Ali Khan Jun 30 '22 at 19:39
  • It takes a lot more than "adding ruby". What does `which ruby` say? What does `which pod` say? – matt Jun 30 '22 at 19:45
  • @matt Okay, here it is `which ruby` - `/usr/local/opt/ruby@2.6/bin/ruby` `ls -lh $(which pod)` - `/usr/local/bin/pod -> ../Cellar/cocoapods/1.11.3/bin/pod` – Saif Ali Khan Jun 30 '22 at 19:47
  • That seems okay! But as you say, it doesn't explain the issue. :( – matt Jun 30 '22 at 20:12
  • I am just not able to figure out that why upgrading react native is causing this problem. – Saif Ali Khan Jun 30 '22 at 20:22
  • What version of CocoaPods is it? `pod --version`. Can you also include your podfile in the question? I had to update my podfile when I switched to the M1 so there may be something there. – Jay Jun 30 '22 at 21:11
  • @Jay `pod --version` is pod `1.11.3`. I have updated the question, added the `podfile` – Saif Ali Khan Jul 01 '22 at 03:49
  • I believe your target needs to be iOS 13 or higher, update your podfile and try again. – Jay Jul 01 '22 at 20:20

1 Answers1

0

I had same problems. I think it is related with "M1 chips", and libraries not ready for it.. https://github.com/realm/realm-js/issues/3199

Tobe honest, I'm still not confident about the reason for this problem. But anyway, I solved this problem through this flow.

  1. I followed this flow from this link How to run CocoaPods on Apple Silicon (M1)
# Uninstall the local cocoapods gem
sudo gem uninstall cocoapods

# Reinstall cocoapods via Homebrew
brew install cocoapods

but you may have problem installing cocoapods through homebrew also. then follow this https://docs.brew.sh/Installation

  1. Turn on "open with rosetta" on 'Xcode'

This flow magically solved my problem. It may not solve your problem, but I believe those links would give you hints to solve your problem.

Good luck!

byyoung
  • 327
  • 3
  • 10
  • Thanks for your answer, although I realised that I was using a pretty older version of realm(as the errors for undefined symbols were mostly of realm), so I upgraded the realm version to `10` and tried clean build and started fresh, and after that, I didn't got this error. – Saif Ali Khan Aug 04 '22 at 02:33
  • I was hoping this was just a M1-related problem, but I went back to my Intel-based Mac and it, unfortunately, had the same problem. So I am stuck for the moment and looking for ideas. – Bruce Cichowlas Dec 22 '22 at 13:54