realm-js: [Bug report] Undefined symbols for architecture x86_64 on Xcode build

Goals

We are getting several errors Undefined symbols for architecture x86_64 when try to build (play) the React Native app with Xcode for iOS.

Here I report the example of two apps, with two different versions of Realm and React Native, both with the same problem.

To solve, we need to:

cd ios
rm -rf Pods
pod install

This happens several times a day, we have not yet discovered the reason.

My guess is that this is related to branch exchange. However, when changing branches, neither React Native nor Realm versions are changed. (ios/Pods and node_modules are ignored on GIT)

React Native 0.62.2 and RealmJS 6.0.2

image

React Native 0.61.5 and RealmJS 3.6.5

image

Steps to Reproduce

Unfortunately, we still haven’t found a standard behavior.

As @somebody32 says here https://github.com/realm/realm-js/issues/3221#issuecomment-723875769

Looks like it is happening every time there is a change in Pods (ie adding a new or upgrading a version of any pod, not Realm). Realm is 10.0.1.

The temporal solution is to clean the build and do pod install again (no need to remove pods or node_modules folder), but I agree that it is pretty time consuming

Code Sample

Both projects are created using react-native init, without any customization in the metro, babel or{{ cocoapods}} scripts.

Version of Realm and Tooling

  • Realm JS SDK Version: 3.6.5 and 6.0.2
  • React Native: RN 0.61.5 and 0.62.2 both with cocoapods and autolinking
  • Cocoapods: 1.9.3
  • Xcode: 11.7 (11E801a)
  • Node: 12.16.3 with nvm
  • Client OS & Version: macOS Catalina 10.15.6 (19G2021)
  • Which debugger for React Native: None

Maybe related to https://github.com/realm/realm-js/issues/2271 https://github.com/realm/realm-cocoa/issues/2393

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 19
  • Comments: 31 (5 by maintainers)

Most upvoted comments

Looks like it is happening every time there is a change in Pods (ie adding a new or upgrading a version of any pod, not Realm). Realm is 10.0.1.

The temporal solution is to clean the build and do pod install again (no need to remove pods or node_modules folder), but I agree that it is pretty time consuming

You can add something like

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

to your app’s pod. See also https://stackoverflow.com/questions/63607158/xcode-12-building-for-ios-simulator-but-linking-in-object-file-built-for-ios

Why it is closed? Reinstall pods take time that is unnecessary. Need to find issue that cause crash on build

I’ve also been encountering this same problem for months now. Been happening on Realm V3, V6 and now V10, so it’s definitely not something caused by some recent change. My solution has been the same, clean build, reinstall pods, but it’s more time-consuming than it needs to be, since it happens every time I need to Pod Install, even if Realm itself doesn’t change.

I wrote some hack for solve this issue for me for a while We need clear build folder and pods, as @douglasjunior says. So, we can do it in postinstall step

bin/postInstall

#!/usr/bin/env node

const childProcess = require('child_process')
const os = require('os')
;[
  // Kill the metro bundler if it's running.
  { command: 'pkill -f "cli.js start" || set exit 0', onlyPlatforms: ['darwin', 'linux'] },

  // on iOS, make sure our native modules are installed
  { command: 'xcodebuild clean', cwd: 'ios', onlyPlatforms: ['darwin'] },
  {
    command: 'rm -rf ~/Library/Developer/Xcode/DerivedData/*',
    cwd: 'ios',
    onlyPlatforms: ['darwin'],
  },
  { command: 'pod install', cwd: 'ios', onlyPlatforms: ['darwin'] },
]
  .filter(({ onlyPlatforms }) => !onlyPlatforms || onlyPlatforms.includes(os.platform()))
  .forEach(commandAndOptions => {
    const { command, onlyPlatform: _, ...options } = commandAndOptions
    try {
      childProcess.execSync(command, {
        stdio: 'inherit',
        ...options,
      })
    } catch (error) {
      process.exit(error.status)
    }
  })

package.json

// other stuff
  "scripts": {
    "preinstall": "rm -rf node_modules && rm -rf ios/Pods",
    "postinstall": "node ./bin/postInstall"
   }
// other stuff

After this, I run project directly from XCode 12 and build success. This solution is not brilliant, but solve the issue

@whalemare We have updated our library to be built with a precompiled xcframework, which should prevent such crashes from occurring and also result in much faster builds. Which version of Realm are you using? Can you verify what steps you are taking to cause the crash?

Here we just need to:

cd ios/
rm -rf Pods/
pod install

No project clean, no cache clean, just reinstall pods, close and open Xcode, build.

The most performant solution is to remove single Pod:

rm -rf Pods/Target\ Support\ Files/RealmJS

When you clean build, reinstall pods (pod deintegrate, rm -rf ~/Library/Caches/CocoaPods, rm -rf Pods) - then it takes much more time for new build.

I just went in a day from 10 min debug/release build to 3 min release build and 2 min debug build by fixing this and removing Flipper from my project 😃 so I’m happy 😃

This fixes the issue I had with Xcode randomly showing 100 errors and stopping in the last 1%. I hope it helps someone 😃

Yes, as I said, removing the Pods folder and installing again temporarily resolves the issue.

But, we still don’t know the reason, the problem appears again, in different projects, different versions, different machines.